diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 1a8eb328b..fc86a3e8d 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -95,11 +95,15 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): { // FIXME: Textbox labels have inconsistent capitalization mTotal = S.Id(ID_TOTAL).AddTextBox(_("&Total space used"), wxT("0"), 10); - mTotal->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); + mTotal->Bind(wxEVT_KEY_DOWN, + // ignore it + [](wxEvent&){}); S.AddVariableText( {} )->Hide(); mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10); - mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); + mAvail->Bind(wxEVT_KEY_DOWN, + // ignore it + [](wxEvent&){}); S.AddVariableText( {} )->Hide(); S.AddPrompt(_("&Levels To Discard")); @@ -117,7 +121,9 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): mDiscard = S.Id(ID_DISCARD).AddButton(_("&Discard")); mClipboard = S.AddTextBox(_("Clipboard space used"), wxT("0"), 10); - mClipboard->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar)); + mClipboard->Bind(wxEVT_KEY_DOWN, + // ignore it + [](wxEvent&){}); S.Id(ID_DISCARD_CLIPBOARD).AddButton(_("Discard")); } S.EndMultiColumn(); @@ -294,9 +300,3 @@ void HistoryWindow::OnSize(wxSizeEvent & WXUNUSED(event)) if (mList->GetItemCount() > 0) mList->EnsureVisible(mSelected); } - -void HistoryWindow::OnChar(wxKeyEvent &event) -{ - event.Skip(false); - return; -} diff --git a/src/HistoryWindow.h b/src/HistoryWindow.h index c7cd68d2c..7b4f17a78 100644 --- a/src/HistoryWindow.h +++ b/src/HistoryWindow.h @@ -38,7 +38,6 @@ class HistoryWindow final : public wxDialogWrapper { void OnSize(wxSizeEvent & event); void OnCloseWindow(wxCloseEvent & WXUNUSED(event)); - void OnChar(wxKeyEvent & event); void OnItemSelected(wxListEvent & event); void OnDiscard(wxCommandEvent & event); void OnDiscardClipboard(wxCommandEvent & event); diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index bc1b2f316..4ce14515b 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -152,6 +152,20 @@ BEGIN_EVENT_TABLE(ContrastDialog,wxDialogWrapper) EVT_BUTTON(wxID_CANCEL, ContrastDialog::OnClose) END_EVENT_TABLE() +static void OnChar(wxKeyEvent & event) +{ + // Is this still required? + if (event.GetKeyCode() == WXK_TAB) { + // pass to next handler + event.Skip(); + return; + } + + // ignore any other key + event.Skip(false); + return; +} + /* i18n-hint: WCAG2 is the 'Web Content Accessibility Guidelines (WCAG) 2.0', see http://www.w3.org/TR/WCAG20/ */ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, const wxString & title, @@ -235,7 +249,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, m_pButton_UseCurrentF = S.Id(ID_BUTTON_USECURRENTF).AddButton(_("&Measure selection")); mForegroundRMSText=S.Id(ID_FOREGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17); - mForegroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mForegroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar); //Background S.AddFixedText(_("&Background:")); @@ -267,7 +281,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, m_pButton_UseCurrentB = S.Id(ID_BUTTON_USECURRENTB).AddButton(_("Mea&sure selection")); mBackgroundRMSText = S.Id(ID_BACKGROUNDDB_TEXT).AddTextBox( {}, wxT(""), 17); - mBackgroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mBackgroundRMSText->Bind(wxEVT_KEY_DOWN, OnChar); } S.EndMultiColumn(); } @@ -280,11 +294,11 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, { S.AddFixedText(_("Co&ntrast Result:")); mPassFailText = S.Id(ID_RESULTS_TEXT).AddTextBox( {}, wxT(""), 50); - mPassFailText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mPassFailText->Bind(wxEVT_KEY_DOWN, OnChar); m_pButton_Reset = S.Id(ID_BUTTON_RESET).AddButton(_("R&eset")); S.AddFixedText(_("&Difference:")); mDiffText = S.Id(ID_RESULTSDB_TEXT).AddTextBox( {}, wxT(""), 50); - mDiffText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar)); + mDiffText->Bind(wxEVT_KEY_DOWN, OnChar); m_pButton_Export = S.Id(ID_BUTTON_EXPORT).AddButton(_("E&xport...")); } S.EndMultiColumn(); @@ -588,15 +602,3 @@ void ContrastDialog::OnReset(wxCommandEvent & /*event*/) mPassFailText->ChangeValue(wxT("")); mDiffText->ChangeValue(wxT("")); } - -void ContrastDialog::OnChar(wxKeyEvent & event) -{ - // Is this still required? - if (event.GetKeyCode() == WXK_TAB) { - event.Skip(); - return; - } - - event.Skip(false); - return; -} diff --git a/src/effects/Contrast.h b/src/effects/Contrast.h index 23dacdc92..023998bdf 100644 --- a/src/effects/Contrast.h +++ b/src/effects/Contrast.h @@ -62,7 +62,6 @@ private: void results(); void OnReset(wxCommandEvent & event); void OnClose(wxCommandEvent & event); - void OnChar(wxKeyEvent &event); wxTextCtrl *mForegroundRMSText; wxTextCtrl *mBackgroundRMSText; diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index b9a5aa655..af78f1966 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -717,7 +717,9 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) mSliders[i] = safenew wxSlider(mGraphicPanel, ID_Slider + i, 0, -20, +20, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE); - mSliders[i]->Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(EffectEqualization::OnErase)); + mSliders[i]->Bind(wxEVT_ERASE_BACKGROUND, + // ignore it + [](wxEvent&){}); #if wxUSE_ACCESSIBILITY wxString name; if( kThirdOct[i] < 1000.) @@ -2592,11 +2594,6 @@ void EffectEqualization::OnSize(wxSizeEvent & event) event.Skip(); } -void EffectEqualization::OnErase(wxEraseEvent & WXUNUSED(event)) -{ - // Ignore it -} - void EffectEqualization::OnSlider(wxCommandEvent & event) { wxSlider *s = (wxSlider *)event.GetEventObject(); diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h index 3b4d4ac05..238e72b72 100644 --- a/src/effects/Equalization.h +++ b/src/effects/Equalization.h @@ -172,7 +172,6 @@ private: double splint(double x[], double y[], size_t n, double y2[], double xr); void OnSize( wxSizeEvent & event ); - void OnErase( wxEraseEvent & event ); void OnSlider( wxCommandEvent & event ); void OnInterp( wxCommandEvent & event ); void OnSliderM( wxCommandEvent & event ); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 101b24832..b6c4d7ad3 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2755,6 +2755,24 @@ void VSTEffect::RemoveHandler() { } +static void OnSize(wxSizeEvent & evt) +{ + evt.Skip(); + + // Once the parent dialog reaches its final size as indicated by + // a non-default minimum size, we set the maximum size to match. + // This is a bit of a hack to prevent VSTs GUI windows from resizing + // there's no real reason to allow it. But, there should be a better + // way of handling it. + wxWindow *w = (wxWindow *) evt.GetEventObject(); + wxSize sz = w->GetMinSize(); + + if (sz != wxDefaultSize) + { + w->SetMaxSize(sz); + } +} + void VSTEffect::BuildFancy() { // Turn the power on...some effects need this when the editor is open @@ -2782,7 +2800,7 @@ void VSTEffect::BuildFancy() NeedEditIdle(true); - mDialog->Connect(wxEVT_SIZE, wxSizeEventHandler(VSTEffect::OnSize)); + mDialog->Bind(wxEVT_SIZE, OnSize); #ifdef __WXMAC__ #ifdef __WX_EVTLOOP_BUSY_WAITING__ @@ -2968,24 +2986,6 @@ void VSTEffect::RefreshParameters(int skip) } } -void VSTEffect::OnSize(wxSizeEvent & evt) -{ - evt.Skip(); - - // Once the parent dialog reaches it's final size as indicated by - // a non-default minimum size, we set the maximum size to match. - // This is a bit of a hack to prevent VSTs GUI windows from resizing - // there's no real reason to allow it. But, there should be a better - // way of handling it. - wxWindow *w = (wxWindow *) evt.GetEventObject(); - wxSize sz = w->GetMinSize(); - - if (sz != wxDefaultSize) - { - w->SetMaxSize(sz); - } -} - void VSTEffect::OnSizeWindow(wxCommandEvent & evt) { if (!mControl) diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 69443c652..33cf391c9 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -195,7 +195,6 @@ private: // UI void OnSlider(wxCommandEvent & evt); - void OnSize(wxSizeEvent & evt); void OnSizeWindow(wxCommandEvent & evt); void OnUpdateDisplay(wxCommandEvent & evt); diff --git a/src/widgets/Grid.h b/src/widgets/Grid.h index 9b44119e1..8992ef48e 100644 --- a/src/widgets/Grid.h +++ b/src/widgets/Grid.h @@ -167,13 +167,15 @@ public: public: void ConnectEvent(wxWindow *w) { - w->GetEventHandler()->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(FocusHandler::OnKillFocus)); + // Need to use a named function pointer, not a lambda, so that we + // can unbind the same later + w->GetEventHandler()->Bind(wxEVT_KILL_FOCUS, OnKillFocus); }; void DisconnectEvent(wxWindow *w) { - w->GetEventHandler()->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(FocusHandler::OnKillFocus)); + w->GetEventHandler()->Unbind(wxEVT_KILL_FOCUS, OnKillFocus); }; - void OnKillFocus(wxFocusEvent & WXUNUSED(event)) + static void OnKillFocus(wxFocusEvent & WXUNUSED(event)) { return; };