[wxPython] EVT_KILL_FOCUS

I have a wxTextCtrl and I would like to save it's
content when the user has finished to input data. For
this purpose I'm using the EVT_KILL_FOCUS.

But I've the following behaviour :

- the EVT_KILL_FOCUS is not triggered when you click
on buttons defined into the Toolbar
- but, the EVT_KILL_FOCUS is triggered when you click
on "normal" button or wxTextCtrl or wxComboBox
- I've defined an EVT_CLOSE for my main window, and if
you close the window by clicking on the usual small
cross (at upper right corner), the EVT_KILL_FOCUS is
triggered after the self.Destroy() ... So, getting the
content of the wxTextCtrl generate a "memory fault".

I tought that the EVT_KILL_FOCUS should be triggered
each time the user click outside my wxTextCtrl.

What do you think ?

evt_kill_focu.py (1.66 KB)

···

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

- I've defined an EVT_CLOSE for my main window, and if
you close the window by clicking on the usual small
cross (at upper right corner), the EVT_KILL_FOCUS is
triggered after the self.Destroy() ... So, getting the
content of the wxTextCtrl generate a "memory fault".

See
http://wiki.wxpython.org/index.cgi/Surviving_20with_20wxEVT_5fKILL_5fFOCUS_2
0under_20Microsoft_20Windows

I tought that the EVT_KILL_FOCUS should be triggered
each time the user click outside my wxTextCtrl.

Only if the focus is actually moved. Toolbars don't take the focus, so it
stays in the text control and so it doesn't send the event.

···

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

vincent delft wrote:

I have a wxTextCtrl and I would like to save it's
content when the user has finished to input data. For
this purpose I'm using the EVT_KILL_FOCUS.

But I've the following behaviour :

- the EVT_KILL_FOCUS is not triggered when you click
on buttons defined into the Toolbar
- but, the EVT_KILL_FOCUS is triggered when you click
on "normal" button or wxTextCtrl or wxComboBox

If you just want to avoid losing the latest changes the user makes to the data in the text control, you could use EVT_TEXT(self.txt, handler_function) to save the value whenever it is modified.

David

Indeed, This was my first action.

But this is not working well (with wxGTK) when some
words are HighLighted (I change the Font color to
WHITE and Bakground color to BLUE).
(My wxTextCtrl is with the style wxTE_RICH.)
It has been recognized as a "bug".

(http://lists.wxwindows.org/pipermail/wxpython-users/2002-January/009521.html)

···

--- "David C. Fox" <davidcfox@mediaone.net> wrote:

vincent delft wrote:

> I have a wxTextCtrl and I would like to save it's
> content when the user has finished to input data.
For
> this purpose I'm using the EVT_KILL_FOCUS.
>
> But I've the following behaviour :
>
> - the EVT_KILL_FOCUS is not triggered when you
click
> on buttons defined into the Toolbar
> - but, the EVT_KILL_FOCUS is triggered when you
click
> on "normal" button or wxTextCtrl or wxComboBox

If you just want to avoid losing the latest changes
the user makes to
the data in the text control, you could use
EVT_TEXT(self.txt,
handler_function) to save the value whenever it is
modified.

David

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org

http://lists.wxwindows.org/mailman/listinfo/wxpython-users

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com