[quote=309718:@Karen Atkocius]Possibly another way… Create a flag in the listbox, set it in CellGotFocus (orLostFocus?) and Check it in Listbox.GotFocus to decide what to do and unset it if it was set
Karen[/quote]
I would do it this way. And make it a listbox subclass so you can share it between projects.
I’ve just amended my program (see link above). The problem should be fixed. Tab and Shift+Tab. Everything is done on keypress so its independent of mouse interaction. The window property ignoreFocus should be a property of your own ListBox control so nothing else has access to it.
Thanks Julian, I’ll have a look at this shortly. Since I’d already got this working after a fashion, I’ve moved on to higher priorities for the past few days, but hope to get back to this in the next day or two.
Thanks also to Tim, Karen and Langue, for the suggestions.
[quote=309718:@Karen Atkocius]Possibly another way… Create a flag in the listbox, set it in CellGotFocus (orLostFocus?) and Check it in Listbox.GotFocus to decide what to do and unset it if it was set
Karen[/quote]
That is not bullet proof. That is because if you are editing a cell, if say you click in a different TextField control so it gets teh focus, CellLostFocus Fires but ListBox LostFocus does not also fire … And IMO it should logically as the the ActiveCell is not an independent control (I guess I should create a feature request or bug report about this subtlety)
But there is a workaround (untried) that should work using a timer to see where the focus goes
The way to make it work is to subclass the listbox and create a new ListBox.LostFocus event (and new Listbox.Gotfocus, CellGotFocus, CellLostFocus events if you want to keep those hooks for other uses) and use a timer started in CellLostFocus.
In the subclass
Create a Flag : IsEditing as Boolean
A method to determine where the focus and to unset the flag if it’s not the list
Sub CheckFocus(theTimer as timer)
If NOT (me.TrueWindow.Focus Is ME) then isEditing = False
End Focus
In the original CellLostFocus call the New CellLostFocus if you want it
In the original CellLostFocus create a single shot timer (or CallLater) and use add handler to make it’s action the CheckFocus method and start it
In the original ListBoxGotFocus call the new CellGotFocus if you want it
check isEditing to decide what to do then set it to False
Unless I missed something, that should always work.