centralized Esc key handling for closing the dialogs in wxDialogBase:

1. added wxDialogBase::OnCharHook() and removed this event handler from
   all the other ports
2. also removed ad hoc code doing the same thing in wxMSW (MSWProcessMessage()
   override in wxDialog) and wxGTK (in gtk_window_key_press_callback())
3. reimplemented EmulateButtonClickIfPresent() portably and also moved it
   to wxDialogBase from wxMSW wxDialog


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40686 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-08-19 22:36:10 +00:00
parent 8f4931874c
commit 0be2741893
12 changed files with 82 additions and 169 deletions

View File

@@ -32,7 +32,6 @@ extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[];
class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
{
public:
enum
{
// all flags allowed in wxDialogBase::CreateButtonSizer()
@@ -72,6 +71,20 @@ public:
#endif // wxUSE_BUTTON
protected:
// emulate click of a button with the given id if it's present in the dialog
//
// return true if button was "clicked" or false if we don't have it
bool EmulateButtonClickIfPresent(int id);
// this function is used by OnCharHook() to decide whether the given key
// should close the dialog
//
// for most platforms the default implementation (which just checks for
// Esc) is sufficient, but Mac port also adds Cmd-. here and other ports
// could do something different if needed
virtual bool IsEscapeKey(const wxKeyEvent& event);
// The return code from modal dialog
int m_returnCode;
@@ -81,6 +94,10 @@ protected:
// The identifier for cancel button (usually wxID_CANCEL)
int m_escapeId;
private:
// handle Esc key presses
void OnCharHook(wxKeyEvent& event);
DECLARE_NO_COPY_CLASS(wxDialogBase)
DECLARE_EVENT_TABLE()
WX_DECLARE_CONTROL_CONTAINER();