[wxPython] wxPanel, wxEVT_CHAR, ESC

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] wxPanel, wxEVT_CHAR, ESC

Niki Spahiev-2
Hello,

I would like to have default ESC key processing in wxPanel the way
wxDialog does it. I set wxEVT_CHAR on panel and every control in it.
This way i can handle F2 key for example but not ESC key.

What else should i do?

Thanks,
Niki Spahiev


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxPanel, wxEVT_CHAR, ESC

Robin Dunn
wxDialog uses EVT_CHAR_HOOK to catch the event.  Here is the event handler
(in C++), you could probably do something similar:


void wxDialog::OnCharHook(wxKeyEvent& event)
{
  if (GetHWND())
  {
    if (event.m_keyCode == WXK_ESCAPE)
    {
        // Behaviour changed in 2.0: we'll send a Cancel message
        // to the dialog instead of Close.
        wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED,
wxID_CANCEL);
        cancelEvent.SetEventObject( this );
        GetEventHandler()->ProcessEvent(cancelEvent);

        return;
    }
  }
  // We didn't process this event.
  event.Skip();
}


----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Thursday, August 19, 1999 6:54 AM
Subject: [wxPython] wxPanel, wxEVT_CHAR, ESC


> Hello,
>
> I would like to have default ESC key processing in wxPanel the way
> wxDialog does it. I set wxEVT_CHAR on panel and every control in it.
> This way i can handle F2 key for example but not ESC key.
>
> What else should i do?
>
> Thanks,
> Niki Spahiev
>
>
> _______________________________________________
> wxPython-users maillist  -  [hidden email]
> http://starship.python.net/mailman/listinfo/wxpython-users
>


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users