diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 0fab52181..0ee91122e 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1876,6 +1876,10 @@ int Effect::GetAudioOutCount() return 0; } +BEGIN_EVENT_TABLE(EffectDialog, wxDialog) + EVT_BUTTON(wxID_OK, EffectDialog::OnOk) +END_EVENT_TABLE() + EffectDialog::EffectDialog(wxWindow * parent, const wxString & title, int type, @@ -1950,6 +1954,21 @@ void EffectDialog::OnPreview(wxCommandEvent & WXUNUSED(event)) return; } +void EffectDialog::OnOk(wxCommandEvent & WXUNUSED(event)) +{ + // On wxGTK (wx2.8.12), the default action is still executed even if + // the button is disabled. This appears to affect all wxDialogs, not + // just our Effects dialogs. So, this is a only temporary workaround + // for legacy effects that disable the OK button. Hopefully this has + // been corrected in wx3. + if (FindWindowById(wxID_OK)->IsEnabled() && Validate() && TransferDataFromWindow()) + { + EndModal(true); + } + + return; +} + /////////////////////////////////////////////////////////////////////////////// // // EffectPanel diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 9ee1710a5..852ab0e98 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -467,10 +467,13 @@ public: virtual bool TransferDataFromWindow(); virtual bool Validate(); virtual void OnPreview(wxCommandEvent & event); + virtual void OnOk(wxCommandEvent & event); private: int mType; int mAdditionalButtons; + + DECLARE_EVENT_TABLE(); }; //