[wxpython-users] Catching user leaving the window
Mike Driscoll
mike at pythonlibrary.org
Mon Sep 8 08:11:57 PDT 2008
Tim,
>
>
> On Mon, Sep 8, 2008 at 3:30 PM, Mike Driscoll <mike at pythonlibrary.org
> <mailto:mike at pythonlibrary.org>> wrote:
>
> Hi Werner,
>
>
> I have a FlatNotebook and use the event
> "EVT_FLATNOTEBOOK_PAGE_CHANGING" to catch page changing to
> ensure that user either saves data before changing to another
> page.
>
> This works fine as long as user goes to another notebook page,
> but if they go "outside" the flatnotebook I can't find an
> event which lets me catch this.
>
> Tried "EVT_CHILD_FOCUS" but that fires very often and I
> haven't figured out a nice way to just rollback the database
> connection in the right situation.
>
> I also tried "EVT_KILL_FOCUS" but does not seem to fire for
> the flatnotebook - is this a known issue?
>
> Do I have any other options?
>
> Werner
>
>
> Did you try EVT_LEAVE_WINDOW ? I would think that would work no
> matter which widget you're using, unless the OS doesn't support it.
>
>
> Doesn't that track mouse-movement? Wouldn't it be a bit extreme to
> rollback your database-transaction and already-entered data just b/c
> the user moves the mouse? ;-)
>
> You could perhaps try window activate/deactivate events, I think that
> these apply only to the whole wx.Frame; not to individual widgets.
>
> Cheers,
>
> --Tim
>
>
Yeah, but sometimes you gotta get extreme! Anyway, I suppose Werner
could just track changes and catch the OnClose event and ask the user if
they want to save or not.
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
More information about the wxpython-users
mailing list