From 9655ca9e687cae9f5117455cbb75cb9e475d80f1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Nov 2017 21:40:24 +0100 Subject: [PATCH] Close the gestures frame too in the event sample Make "Exit" menu item really exit the sample again instead of just closing the main window, but possibly leaving the gestures testing window still open and thus not really exiting the program. Also avoid creating more than one gesture window, use the existing one if we had already opened it. --- samples/event/event.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/event/event.cpp b/samples/event/event.cpp index 7e1af4cf80..8cc96efd18 100644 --- a/samples/event/event.cpp +++ b/samples/event/event.cpp @@ -182,7 +182,7 @@ private: // the button used to highlight the event handlers execution order MyEvtTestButton *m_testBtn; - MyGestureFrame *m_gestureFrame; + wxWindowRef m_gestureFrame; // any class wishing to process wxWidgets events must use this macro @@ -457,7 +457,8 @@ MyFrame::~MyFrame() void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { - // true is to force the frame to close + if ( m_gestureFrame ) + m_gestureFrame->Close(true); Close(true); } @@ -589,8 +590,15 @@ void MyFrame::OnPopEventHandler(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnGesture(wxCommandEvent& WXUNUSED(event)) { - m_gestureFrame = new MyGestureFrame(); - m_gestureFrame->Show(true); + if ( m_gestureFrame ) + { + m_gestureFrame->Raise(); + } + else + { + m_gestureFrame = new MyGestureFrame(); + m_gestureFrame->Show(true); + } } void MyFrame::OnTest(wxCommandEvent& WXUNUSED(event))