[wxPython-users] Re: BitmapButton shows focus erroneously

Robin Dunn robin at alldunn.com
Sat Jun 3 11:46:34 PDT 2006


Jeffrey Barish wrote:
> Robin Dunn wrote:
> 
>> 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()
>>
> You are right: This change solves the problem with focus.  But now I can't
> get the button to do anything because it no longer produces EVT_BUTTON. 
> Wait, I wasn't getting EVT_BUTTON in the original version of the test
> (without the CallAfter) either.  I'm confused because the buttons still
> work in the actual program even though they go into the metafocus mode.

This is strange.  Perhaps the native control is checking focus before 
sending of the button event, or something like that.  (As further 
evidence of this being a native behavior, it works fine in wxGTK.)  In 
any case you can just move your SetFocus call to a EVT_BUTTON handler.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list