Intercepting escape key with a wxTextCtrl

I would like to intercept the escape key in a wxTextCtrl so that
users could abandon changes and revert to a previous (validated)
value. How do I do that? I tried using EVT_CHAR, but that doesn't
seem to do anything with a text control...

Thanks in advance.

···

-------------------------------------------------------------------------------------
Jeff Kotula Systems Architecture Manager
Vital Images jkotula@vitalimages.com

Renunciation is not giving up the things of this world,
but accepting that they go away.
    -- Suzuki Roshi

Jeff Kotula wrote:

I would like to intercept the escape key in a wxTextCtrl so that
users could abandon changes and revert to a previous (validated)
value. How do I do that? I tried using EVT_CHAR, but that doesn't
seem to do anything with a text control...

Try with EVT_KEY_DOWN. EVT_CHAR occurs after the key has been "translated" by the default key event handlers. If you want to intercept a key event before a controll processes it then usually EVT_CHAR is too late.

···

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

I don't know if this helps, but I use the following to detect Escape key
presses in dialogs in order to cancel the dialog:

    EVT_CHAR_HOOK(self, self.OnCharHook)
.
.
    def OnCharHook(self, event):
        if event.KeyCode() == 27: #esc
            self.EndModal(wxID_CANCEL)
        event.Skip()

Once you have caught the event, I guess, you can then do what you like.

Regards,

David Hughes
Forestfield Software Ltd
www.forestfield.co.uk

Is it possible to use images instead of text in wxChoice?

Tiago Duarte Felix wrote:

Is it possible to use images instead of text in wxChoice?

Not with any of the standard controls, but creating a custom control for this wouldn't be too hard.

···

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

in wxChoice?

Tiago Duarte Felix wrote:
> Is it possible to use images instead of text in wxChoice?
>
>

Not with any of the standard controls, but creating a custom control for
this wouldn't be too hard.

How can i create a custom control of that kind... just need an idea of how
to do it... never done anything of that king....

···

----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxPython-users@lists.wxwindows.org>
Sent: Friday, November 15, 2002 2:22 AM
Subject: Re: [wxPython-users] Is it possible to use images instead of text

Tiago Duarte Felix wrote:

Tiago Duarte Felix wrote:

Is it possible to use images instead of text in wxChoice?

Not with any of the standard controls, but creating a custom control for
this wouldn't be too hard.

How can i create a custom control of that kind... just need an idea of how
to do it... never done anything of that king....

Take a look at wxPython/lib/buttons.py for starters. Just derive a class from wxControl, put a wxScrolledWindow on it (or manage the scrollbar yourself directly on the wxControl) and then hook the mouse events and the EVT_PAINT event. In the paint handler draw your images, including any that are "selected" In the mouse handlers change the state of selected items as needed and redraw the affected items.

···

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