Hello Experts,
I have a simple code in the CellClick event of a listbox:
#If TargetWindows Then
If Keyboard.AsyncControlKey Then
dim t as folderitem = GetFolderItem(Me.RowTag(Me.ListIndex), FolderItem.PathTypeShell)
If t <> nil and t.Exists then
if t.Directory then
t.launch
else
t.parent.launch
End if
End If
End If
#Elseif TargetMacOS Then
If Keyboard.AsyncCommandKey Then
dim t as folderitem = GetFolderItem(Me.RowTag(Me.ListIndex), FolderItem.PathTypeShell)
If t <> nil and t.Exists then
if t.Directory then
t.launch
else
t.parent.launch
End if
End If
End If
#Endif
The Listbox.RowTag inhabit the shell path of a previously dropped file onto the listbox and already been checked and double checked.
The odd thing is when I click+Ctrl(win) or click+cmd(mac) while the listbox item is “in focus” everything works perfect, but when I do the same action while the focus is on the window or completely outside of the app the debugger jumps with an OutOfBoundsException.
I tried to set the focus to the listbox item but couldn’t make it work, Even tried to add ‘Try…Catch’ like so:
If Keyboard.AsyncControlKey Then
Try
dim t as folderitem = GetFolderItem(Me.RowTag(Me.ListIndex), FolderItem.PathTypeShell)
If t <> nil and t.Exists then
if t.Directory then
t.launch
else
t.parent.launch
End if
End If
Catch er As RuntimeException
If er IsA NilObjectException Then
Window1.Messages_Area.Text = "First select the item then ctrl+click it"
Else
Raise er
End If
Catch eo As OutOfBoundsException
Window1.Messages_Area.Text = "First select the item then ctrl+click it"
End Try
End If
But that didn’t help either.
I just want to get rid of the OutOfBounds I don’t care if it doesn’t do what it’s supposed to do when out of focus (well, it would be nice too of course, but in second priority for now)
Open to ideas.