mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 15:20:15 +02:00
Bug1273: Restore 2.1.1 behavior of Metadata editor OK, Cancel, ESC...
Click twice on a grid cell; Cancel or OK dismiss the dialog. But ESC does not, and a second ESC does not either. ESC dismisses the dialog only if the focus is not in the grid.
This commit is contained in:
parent
9dcb2c87c3
commit
c1ca055fa4
20
src/Tags.cpp
20
src/Tags.cpp
@ -663,6 +663,7 @@ BEGIN_EVENT_TABLE(TagsEditor, wxDialog)
|
|||||||
EVT_BUTTON(RemoveID, TagsEditor::OnRemove)
|
EVT_BUTTON(RemoveID, TagsEditor::OnRemove)
|
||||||
EVT_BUTTON(wxID_CANCEL, TagsEditor::OnCancel)
|
EVT_BUTTON(wxID_CANCEL, TagsEditor::OnCancel)
|
||||||
EVT_BUTTON(wxID_OK, TagsEditor::OnOk)
|
EVT_BUTTON(wxID_OK, TagsEditor::OnOk)
|
||||||
|
EVT_KEY_DOWN(TagsEditor::OnKeyDown)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
TagsEditor::TagsEditor(wxWindow * parent,
|
TagsEditor::TagsEditor(wxWindow * parent,
|
||||||
@ -1261,7 +1262,6 @@ void TagsEditor::OnOk(wxCommandEvent & WXUNUSED(event))
|
|||||||
if (mGrid->IsCellEditControlShown()) {
|
if (mGrid->IsCellEditControlShown()) {
|
||||||
mGrid->SaveEditControlValue();
|
mGrid->SaveEditControlValue();
|
||||||
mGrid->HideCellEditControl();
|
mGrid->HideCellEditControl();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Validate() || !TransferDataFromWindow()) {
|
if (!Validate() || !TransferDataFromWindow()) {
|
||||||
@ -1281,6 +1281,11 @@ void TagsEditor::OnOk(wxCommandEvent & WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TagsEditor::OnCancel(wxCommandEvent & WXUNUSED(event))
|
void TagsEditor::OnCancel(wxCommandEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
DoCancel(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TagsEditor::DoCancel(bool escKey)
|
||||||
{
|
{
|
||||||
if (mGrid->IsCellEditControlShown()) {
|
if (mGrid->IsCellEditControlShown()) {
|
||||||
auto editor = mGrid->GetCellEditor(mGrid->GetGridCursorRow(),
|
auto editor = mGrid->GetCellEditor(mGrid->GetGridCursorRow(),
|
||||||
@ -1289,12 +1294,23 @@ void TagsEditor::OnCancel(wxCommandEvent & WXUNUSED(event))
|
|||||||
// To avoid memory leak, don't forget DecRef()!
|
// To avoid memory leak, don't forget DecRef()!
|
||||||
editor->DecRef();
|
editor->DecRef();
|
||||||
mGrid->HideCellEditControl();
|
mGrid->HideCellEditControl();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto focus = wxWindow::FindFocus();
|
||||||
|
if (escKey && focus == mGrid)
|
||||||
|
return;
|
||||||
|
|
||||||
EndModal(wxID_CANCEL);
|
EndModal(wxID_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TagsEditor::OnKeyDown(wxKeyEvent &event)
|
||||||
|
{
|
||||||
|
if (event.GetKeyCode() == WXK_ESCAPE)
|
||||||
|
DoCancel(true);
|
||||||
|
else
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void TagsEditor::SetEditors()
|
void TagsEditor::SetEditors()
|
||||||
{
|
{
|
||||||
int cnt = mGrid->GetNumberRows();
|
int cnt = mGrid->GetNumberRows();
|
||||||
|
@ -147,6 +147,8 @@ class TagsEditor final : public wxDialog
|
|||||||
|
|
||||||
virtual ~TagsEditor();
|
virtual ~TagsEditor();
|
||||||
|
|
||||||
|
bool IsEscapeKey(const wxKeyEvent& event) override { return false; }
|
||||||
|
|
||||||
void PopulateOrExchange(ShuttleGui & S);
|
void PopulateOrExchange(ShuttleGui & S);
|
||||||
|
|
||||||
bool TransferDataToWindow() override;
|
bool TransferDataToWindow() override;
|
||||||
@ -171,8 +173,11 @@ class TagsEditor final : public wxDialog
|
|||||||
void OnRemove(wxCommandEvent & event);
|
void OnRemove(wxCommandEvent & event);
|
||||||
|
|
||||||
void OnOk(wxCommandEvent & event);
|
void OnOk(wxCommandEvent & event);
|
||||||
|
void DoCancel(bool escKey);
|
||||||
void OnCancel(wxCommandEvent & event);
|
void OnCancel(wxCommandEvent & event);
|
||||||
|
|
||||||
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
|
|
||||||
bool IsWindowRectValid(const wxRect *windowRect) const;
|
bool IsWindowRectValid(const wxRect *windowRect) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user