Frank Millman wrote:
> Hi all
>
> I have been using EVT_NAVIGATION_KEY in my program to force 'skipping'
of a
> control and passing focus to the next/previous control. I have just
> discovered that it does not work correctly under GTK.
>
> It works correctly the first time. If you then tab through all the
controls
> until focus is set on the same control again, it blocks all navigation
in
> that direction. You can tab backwards until you reach the same control
from
> the other direction, and then it blocks again.
Robin Dunn wrote:
Your sample works for me (2.5.1.5 GTK2 unicode build, but I don't think
that should matter here.)
I have some more information, and I have a solution.
The problem is not caused by EVT_NAVIGATION_KEY itself. It stems from
setting focus on a control from within the GotFocus() event of another
control. It seems that GTK has a problem if the GotFocus() event does not
run through to completion.
This is the offending line -
self.GetEventHandler().ProcessEvent(myevt)
My first attempt at a solution was -
wx.CallAfter(self.GetEventHandler().ProcessEvent,myevt)
This worked, but then I found a nicer one -
self.GetEventHandler().AddPendingEvent(myevt)
I have just discovered a very similar problem with my validation routine. It
is run from every GotFocus() event, and checks the previous control. If it
finds an error, it sets focus on that control, and displays an error dialog.
I am 99% sure that this used to work with an earlier version - prior to
2.4.2.4 - as I tested it thoroughly, but now it shows the same symptoms as
the ones I reported. Wrapping the SetFocus() in a wx.CallAfter has solved
that problem as well.
Thanks
Frank