ESC key

Hello,

I added the following code:

      EVT_KEY_DOWN(self, self.onKeyDown)

   def onKeyDown(self, event):
      """Key down event handler."""
      key = event.KeyCode()
      if key == wx.WXK_ESCAPE:
         self.entry.SetValue("")
      return

And it works in wxGTK2 (clears the text box when I press ESC), but does nothing
in Windows. Why?

Regards,
Nerijus

Nerijus Baliunas wrote:

Hello,

I added the following code:

      EVT_KEY_DOWN(self, self.onKeyDown)

   def onKeyDown(self, event):
      """Key down event handler."""
      key = event.KeyCode()
      if key == wx.WXK_ESCAPE:
         self.entry.SetValue("")
      return

And it works in wxGTK2 (clears the text box when I press ESC), but does nothing
in Windows. Why?

What is self? Where is the focus?

···

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

Saturday, February 18, 2006, 2:25:38 PM, Nerijus Baliunas wrote:

Hello,

I added the following code:

      EVT_KEY_DOWN(self, self.onKeyDown)

   def onKeyDown(self, event):
      """Key down event handler."""
      key = event.KeyCode()
      if key == wx.WXK_ESCAPE:
         self.entry.SetValue("")
      return

And it works in wxGTK2 (clears the text box when I press ESC), but
does nothing in Windows. Why?

Instead of 'EVT_KEY_DOWN(self, self.onKeyDown)', use this:

     self.entry.Bind(wx.EVT_KEY_DOWN, self.onKeyDown)

-- tacao

No bits were harmed during the making of this e-mail.

It works on Windows, but then I cannot enter anything in the text box on Linux:(

Regards,
Nerijus

···

On Sat, 18 Feb 2006 18:22:01 -0300 "E. A. Tacao" <tacao@mailshack.com> wrote:

Instead of 'EVT_KEY_DOWN(self, self.onKeyDown)', use this:

     self.entry.Bind(wx.EVT_KEY_DOWN, self.onKeyDown)

http://cvs.sourceforge.net/viewcvs.py/opendict/opendict/lib/gui/mainwin.py?rev=1.93&view=markup
Just search for KeyDown.

Regards,
Nerijus

···

On Sat, 18 Feb 2006 13:10:09 -0800 Robin Dunn <robin@alldunn.com> wrote:

> I added the following code:
>
> EVT_KEY_DOWN(self, self.onKeyDown)
>
> def onKeyDown(self, event):
> """Key down event handler."""
> key = event.KeyCode()
> if key == wx.WXK_ESCAPE:
> self.entry.SetValue("")
> return
>
> And it works in wxGTK2 (clears the text box when I press ESC), but does nothing
> in Windows. Why?

What is self? Where is the focus?

Saturday, February 18, 2006, 6:33:48 PM, Nerijus Baliunas wrote:

···

On Sat, 18 Feb 2006 18:22:01 -0300 "E. A. Tacao" wrote:

Instead of 'EVT_KEY_DOWN(self, self.onKeyDown)', use this:

     self.entry.Bind(wx.EVT_KEY_DOWN, self.onKeyDown)

It works on Windows, but then I cannot enter anything in the text
box on Linux:(

Replace the 'return' statement on your onKeyDown method to
'event.Skip()'

-- tacao

No bits were harmed during the making of this e-mail.

It works, thank you.

Regards,
Nerijus

···

On Sat, 18 Feb 2006 19:53:12 -0300 "E. A. Tacao" <tacao@mailshack.com> wrote:

> It works on Windows, but then I cannot enter anything in the text
> box on Linux:(

Replace the 'return' statement on your onKeyDown method to
'event.Skip()'