Fixes "Add instance" and "Remove instance" hotkeys don't work when object is selected via de object browser #5350

Captures the +- hotkeys in the object list to add / remove an instance.
This commit is contained in:
Vojtech Bubnik 2020-12-08 08:30:15 +01:00
parent a6dd6d617e
commit 6fe0b09a04
2 changed files with 22 additions and 2 deletions

View file

@ -191,7 +191,7 @@ ObjectList::ObjectList(wxWindow* parent) :
// Bind(wxEVT_KEY_DOWN, &ObjectList::OnChar, this);
{
// Accelerators
wxAcceleratorEntry entries[8];
wxAcceleratorEntry entries[10];
entries[0].Set(wxACCEL_CTRL, (int) 'C', wxID_COPY);
entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_CUT);
entries[2].Set(wxACCEL_CTRL, (int) 'V', wxID_PASTE);
@ -200,7 +200,9 @@ ObjectList::ObjectList(wxWindow* parent) :
entries[5].Set(wxACCEL_CTRL, (int) 'Y', wxID_REDO);
entries[6].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_DELETE);
entries[7].Set(wxACCEL_NORMAL, WXK_BACK, wxID_DELETE);
wxAcceleratorTable accel(8, entries);
entries[8].Set(wxACCEL_NORMAL, int('+'), wxID_ADD);
entries[9].Set(wxACCEL_NORMAL, int('-'), wxID_REMOVE);
wxAcceleratorTable accel(10, entries);
SetAcceleratorTable(accel);
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->copy(); }, wxID_COPY);
@ -209,6 +211,8 @@ ObjectList::ObjectList(wxWindow* parent) :
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);
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->increase_instance(); }, wxID_ADD);
this->Bind(wxEVT_MENU, [this](wxCommandEvent &evt) { this->decrease_instance(); }, wxID_REMOVE);
}
#else //__WXOSX__
Bind(wxEVT_CHAR, [this](wxKeyEvent& event) { key_event(event); }); // doesn't work on OSX
@ -1092,6 +1096,16 @@ void ObjectList::redo()
wxGetApp().plater()->redo();
}
void ObjectList::increase_instances()
{
wxGetApp().plater()->increase_instances(1);
}
void ObjectList::decrease_instances()
{
wxGetApp().plater()->decrease_instances(1);
}
#ifndef __WXOSX__
void ObjectList::key_event(wxKeyEvent& event)
{
@ -1116,6 +1130,10 @@ void ObjectList::key_event(wxKeyEvent& event)
redo();
else if (wxGetKeyState(wxKeyCode('Z')) && wxGetKeyState(WXK_CONTROL))
undo();
else if (event.GetUnicodeKey() == '+')
increase_instances();
else if (event.GetUnicodeKey() == '-')
decrease_instances();
else
event.Skip();
}

View file

@ -257,6 +257,8 @@ public:
bool paste_from_clipboard();
void undo();
void redo();
void increase_instances();
void decrease_instances();
void get_settings_choice(const wxString& category_name);
void get_freq_settings_choice(const wxString& bundle_name);