EVT_LEAVE_WINDOW Test

Hi folks,

I need to implement a "smart focus", i.e. when the mouse leaves a certain wxFrame, to switch the focus to the window beneath it. To do this I hooked the EVT_LEAVE_WINDOW event but the handler is never called. Anyone could please share a piece of advice?

Thank you,

Cristina.

···

-------------------
from wxPython.wx import *

class TestFrame(wxFrame):
     def __init__(self, parent):
         wxFrame.__init__(self, parent, -1, "EVT_LEAVE_WINDOW Test",
                          size=(400,120))
         EVT_CLOSE(self, self.OnCloseWindow)
         EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)

     def OnLeaveWindow(self, event):
         print 'Leaving Frame...'

     def OnCloseWindow(self, event):
         self.Destroy()

#---------------------------------------------------------------------------

if __name__ == '__main__':
     import sys
     app = wxPySimpleApp()
     frame = TestFrame(None)
     frame.Show(true)
     app.MainLoop()

Try this, it *may* work:

         id = wxNewId()
         wxFrame.__init__(self, parent, id, "EVT_LEAVE_WINDOW Test",
                          size=(400,120))
         EVT_CLOSE(id, self.OnCloseWindow)
         EVT_LEAVE_WINDOW(id, self.OnLeaveWindow)

/Jean Brouwers

···

On Sunday, November 23, 2003, at 12:35 PM, C. Iacob wrote:

Hi folks,

I need to implement a "smart focus", i.e. when the mouse leaves a certain wxFrame, to switch the focus to the window beneath it. To do this I hooked the EVT_LEAVE_WINDOW event but the handler is never called. Anyone could please share a piece of advice?

Thank you,

Cristina.
-------------------
from wxPython.wx import *

class TestFrame(wxFrame):
    def __init__(self, parent):
        wxFrame.__init__(self, parent, -1, "EVT_LEAVE_WINDOW Test",
                         size=(400,120))
        EVT_CLOSE(self, self.OnCloseWindow)
        EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)

    def OnLeaveWindow(self, event):
        print 'Leaving Frame...'

    def OnCloseWindow(self, event):
        self.Destroy()

#---------------------------------------------------------------------------

if __name__ == '__main__':
    import sys
    app = wxPySimpleApp()
    frame = TestFrame(None)
    frame.Show(true)
    app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org