[wxPython-users] BitmapButton shows focus erroneously
Robin Dunn
robin at alldunn.com
Fri Jun 2 19:30:45 PDT 2006
Jeffrey Barish wrote:
> Consider the attached program. The BitmapButton has a left arrow (taken
> from the demo program). It changes to a right arrow when the button has
> focus. The button should never have focus because the handler for the set
> focus event assigns the focus to the TextCtrl. However, if you click on
> the button or hit tab, the button will show the telltale dashed line
> indicating that it has focus and the bitmap will change to the right arrow.
> It doesn't really have focus, though, as keyboard input still goes to the
> TextCtrl. The BitmapButton seems to be in a strange state where it thinks
> that it has focus but doesn't.
Because it has already lost the focus (and processed that event) before
it has a chance to finish processing the EVT_SET_FOCUS event. If you
defer the call to SetFocus then it will work as you expect.
def doSetFocusEvent(self, event):
wx.CallAfter(self.textctrl.SetFocus)
event.Skip()
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list