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(wxID_CANCEL, TagsEditor::OnCancel)
|
||||
EVT_BUTTON(wxID_OK, TagsEditor::OnOk)
|
||||
EVT_KEY_DOWN(TagsEditor::OnKeyDown)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
TagsEditor::TagsEditor(wxWindow * parent,
|
||||
|
@ -1261,7 +1262,6 @@ void TagsEditor::OnOk(wxCommandEvent & WXUNUSED(event))
|
|||
if (mGrid->IsCellEditControlShown()) {
|
||||
mGrid->SaveEditControlValue();
|
||||
mGrid->HideCellEditControl();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Validate() || !TransferDataFromWindow()) {
|
||||
|
@ -1281,6 +1281,11 @@ void TagsEditor::OnOk(wxCommandEvent & WXUNUSED(event))
|
|||
}
|
||||
|
||||
void TagsEditor::OnCancel(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
DoCancel(false);
|
||||
}
|
||||
|
||||
void TagsEditor::DoCancel(bool escKey)
|
||||
{
|
||||
if (mGrid->IsCellEditControlShown()) {
|
||||
auto editor = mGrid->GetCellEditor(mGrid->GetGridCursorRow(),
|
||||
|
@ -1289,12 +1294,23 @@ void TagsEditor::OnCancel(wxCommandEvent & WXUNUSED(event))
|
|||
// To avoid memory leak, don't forget DecRef()!
|
||||
editor->DecRef();
|
||||
mGrid->HideCellEditControl();
|
||||
return;
|
||||
}
|
||||
|
||||
auto focus = wxWindow::FindFocus();
|
||||
if (escKey && focus == mGrid)
|
||||
return;
|
||||
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void TagsEditor::OnKeyDown(wxKeyEvent &event)
|
||||
{
|
||||
if (event.GetKeyCode() == WXK_ESCAPE)
|
||||
DoCancel(true);
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void TagsEditor::SetEditors()
|
||||
{
|
||||
int cnt = mGrid->GetNumberRows();
|
||||
|
|
|
@ -147,6 +147,8 @@ class TagsEditor final : public wxDialog
|
|||
|
||||
virtual ~TagsEditor();
|
||||
|
||||
bool IsEscapeKey(const wxKeyEvent& event) override { return false; }
|
||||
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
|
||||
bool TransferDataToWindow() override;
|
||||
|
@ -171,8 +173,11 @@ class TagsEditor final : public wxDialog
|
|||
void OnRemove(wxCommandEvent & event);
|
||||
|
||||
void OnOk(wxCommandEvent & event);
|
||||
void DoCancel(bool escKey);
|
||||
void OnCancel(wxCommandEvent & event);
|
||||
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
|
||||
bool IsWindowRectValid(const wxRect *windowRect) const;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue