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:
@@ -1152,43 +1152,6 @@ gtk_window_key_press_callback( GtkWidget *widget,
|
||||
ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event );
|
||||
}
|
||||
|
||||
// generate wxID_CANCEL if <esc> has been pressed (typically in dialogs)
|
||||
if ( !ret &&
|
||||
(gdk_event->keyval == GDK_Escape) )
|
||||
{
|
||||
// however only do it if we have a Cancel button in the dialog,
|
||||
// otherwise the user code may get confused by the events from a
|
||||
// nonexistent button and, worse, a wxButton might get button event
|
||||
// from another button which is not really expected
|
||||
wxWindow *winForCancel = win,
|
||||
*btnCancel = NULL;
|
||||
while ( winForCancel )
|
||||
{
|
||||
btnCancel = winForCancel->FindWindow(wxID_CANCEL);
|
||||
if ( btnCancel )
|
||||
{
|
||||
// found a cancel button
|
||||
break;
|
||||
}
|
||||
|
||||
if ( winForCancel->IsTopLevel() )
|
||||
{
|
||||
// no need to look further
|
||||
break;
|
||||
}
|
||||
|
||||
// maybe our parent has a cancel button?
|
||||
winForCancel = winForCancel->GetParent();
|
||||
}
|
||||
|
||||
if ( btnCancel )
|
||||
{
|
||||
wxCommandEvent eventClick(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
eventClick.SetEventObject(btnCancel);
|
||||
ret = btnCancel->GetEventHandler()->ProcessEvent(eventClick);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
g_signal_stop_emission_by_name (widget, "key_press_event");
|
||||
|
Reference in New Issue
Block a user