Undo / Redo: Bound Ctrl-V/Ctrl-Z to the side panel.
This commit is contained in:
parent
45a5487e51
commit
fb725502b7
2 changed files with 24 additions and 4 deletions
|
@ -143,20 +143,24 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||||
// Bind(wxEVT_KEY_DOWN, &ObjectList::OnChar, this);
|
// Bind(wxEVT_KEY_DOWN, &ObjectList::OnChar, this);
|
||||||
{
|
{
|
||||||
// Accelerators
|
// Accelerators
|
||||||
wxAcceleratorEntry entries[6];
|
wxAcceleratorEntry entries[8];
|
||||||
entries[0].Set(wxACCEL_CTRL, (int) 'C', wxID_COPY);
|
entries[0].Set(wxACCEL_CTRL, (int) 'C', wxID_COPY);
|
||||||
entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_CUT);
|
entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_CUT);
|
||||||
entries[2].Set(wxACCEL_CTRL, (int) 'V', wxID_PASTE);
|
entries[2].Set(wxACCEL_CTRL, (int) 'V', wxID_PASTE);
|
||||||
entries[3].Set(wxACCEL_CTRL, (int) 'A', wxID_SELECTALL);
|
entries[3].Set(wxACCEL_CTRL, (int) 'A', wxID_SELECTALL);
|
||||||
entries[4].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_DELETE);
|
entries[4].Set(wxACCEL_CTRL, (int) 'Z', wxID_UNDO);
|
||||||
entries[5].Set(wxACCEL_NORMAL, WXK_BACK, wxID_DELETE);
|
entries[5].Set(wxACCEL_CTRL, (int) 'Y', wxID_REDO);
|
||||||
wxAcceleratorTable accel(6, entries);
|
entries[6].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_DELETE);
|
||||||
|
entries[7].Set(wxACCEL_NORMAL, WXK_BACK, wxID_DELETE);
|
||||||
|
wxAcceleratorTable accel(8, entries);
|
||||||
SetAcceleratorTable(accel);
|
SetAcceleratorTable(accel);
|
||||||
|
|
||||||
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->copy(); }, wxID_COPY);
|
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->copy(); }, wxID_COPY);
|
||||||
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->paste(); }, wxID_PASTE);
|
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->paste(); }, wxID_PASTE);
|
||||||
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->select_item_all_children(); }, wxID_SELECTALL);
|
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->select_item_all_children(); }, wxID_SELECTALL);
|
||||||
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->remove(); }, wxID_DELETE);
|
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->remove(); }, wxID_DELETE);
|
||||||
|
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->undo(); }, wxID_UNDO);
|
||||||
|
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->redo(); }, wxID_REDO);
|
||||||
}
|
}
|
||||||
#else __WXOSX__
|
#else __WXOSX__
|
||||||
Bind(wxEVT_CHAR, [this](wxKeyEvent& event) { key_event(event); }); // doesn't work on OSX
|
Bind(wxEVT_CHAR, [this](wxKeyEvent& event) { key_event(event); }); // doesn't work on OSX
|
||||||
|
@ -809,6 +813,16 @@ void ObjectList::paste()
|
||||||
wxPostEvent((wxEvtHandler*)wxGetApp().plater()->canvas3D()->get_wxglcanvas(), SimpleEvent(EVT_GLTOOLBAR_PASTE));
|
wxPostEvent((wxEvtHandler*)wxGetApp().plater()->canvas3D()->get_wxglcanvas(), SimpleEvent(EVT_GLTOOLBAR_PASTE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectList::undo()
|
||||||
|
{
|
||||||
|
wxGetApp().plater()->undo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectList::redo()
|
||||||
|
{
|
||||||
|
wxGetApp().plater()->redo();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __WXOSX__
|
#ifndef __WXOSX__
|
||||||
void ObjectList::key_event(wxKeyEvent& event)
|
void ObjectList::key_event(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
|
@ -827,6 +841,10 @@ void ObjectList::key_event(wxKeyEvent& event)
|
||||||
copy();
|
copy();
|
||||||
else if (wxGetKeyState(wxKeyCode('V')) && wxGetKeyState(WXK_CONTROL))
|
else if (wxGetKeyState(wxKeyCode('V')) && wxGetKeyState(WXK_CONTROL))
|
||||||
paste();
|
paste();
|
||||||
|
else if (wxGetKeyState(wxKeyCode('Y')) && wxGetKeyState(WXK_CONTROL))
|
||||||
|
redo();
|
||||||
|
else if (wxGetKeyState(wxKeyCode('Z')) && wxGetKeyState(WXK_CONTROL))
|
||||||
|
undo();
|
||||||
else
|
else
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,6 +204,8 @@ public:
|
||||||
|
|
||||||
void copy();
|
void copy();
|
||||||
void paste();
|
void paste();
|
||||||
|
void undo();
|
||||||
|
void redo();
|
||||||
|
|
||||||
void get_settings_choice(const wxString& category_name);
|
void get_settings_choice(const wxString& category_name);
|
||||||
void get_freq_settings_choice(const wxString& bundle_name);
|
void get_freq_settings_choice(const wxString& bundle_name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue