ENH:keyboard shortcut in macos
1.fix:global shortcut cannot use in webview panel 2.fix:ban original web-shortcut in webview 3.add cmd+q & cmd+h shortcut in macos 4.move some global shortcut to prepare panel Change-Id: I17ba3c86069dab92df754a319d0c0c3d77b34d74
This commit is contained in:
parent
042e17952c
commit
1a8e5295b2
|
@ -142,6 +142,35 @@
|
||||||
</body>
|
</body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//HandleStudio(TestData);
|
//HandleStudio(TestData);
|
||||||
|
document.onkeydown = function (event) {
|
||||||
|
var e = event || window.event || arguments.callee.caller.arguments[0];
|
||||||
|
|
||||||
|
if (e.shiftKey && e.ctrlKey)
|
||||||
|
OutputKey(e.keyCode, true, true, false);
|
||||||
|
else if (e.ctrlKey)
|
||||||
|
OutputKey(e.keyCode, true, false, false);
|
||||||
|
else if (e.keyCode === 27)
|
||||||
|
OutputKey(e.keyCode, false, false, false);
|
||||||
|
|
||||||
|
if (e.shiftKey && e.metaKey)
|
||||||
|
OutputKey(e.keyCode, false, true, true);
|
||||||
|
else if (e.metaKey)
|
||||||
|
OutputKey(e.keyCode, false, false, true);
|
||||||
|
else if (e.keyCode === 27)
|
||||||
|
OutputKey(e.keyCode, false, false, false);
|
||||||
|
|
||||||
|
if (window.event) {
|
||||||
|
try { e.keyCode = 0; } catch (e) { }
|
||||||
|
e.returnValue = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('mousewheel', function (event) {
|
||||||
|
if (event.ctrlKey === true || event.metaKey) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}, { passive: false });
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -215,4 +215,16 @@ function BeginDownloadNetworkPlugin()
|
||||||
SendWXMessage( JSON.stringify(tSend) );
|
SendWXMessage( JSON.stringify(tSend) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function OutputKey(keyCode, isCtrlDown, isShiftDown, isCmdDown) {
|
||||||
|
var tSend = {};
|
||||||
|
tSend['sequence_id'] = Math.round(new Date() / 1000);
|
||||||
|
tSend['command'] = "get_web_shortcut";
|
||||||
|
tSend['key_event'] = {};
|
||||||
|
tSend['key_event']['key'] = keyCode;
|
||||||
|
tSend['key_event']['ctrl'] = isCtrlDown;
|
||||||
|
tSend['key_event']['shift'] = isShiftDown;
|
||||||
|
tSend['key_event']['cmd'] = isCmdDown;
|
||||||
|
|
||||||
|
SendWXMessage(JSON.stringify(tSend));
|
||||||
|
}
|
||||||
window.postMessage = HandleStudio;
|
window.postMessage = HandleStudio;
|
||||||
|
|
|
@ -2948,6 +2948,26 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
||||||
}
|
}
|
||||||
else if (command_str.compare("begin_network_plugin_download") == 0) {
|
else if (command_str.compare("begin_network_plugin_download") == 0) {
|
||||||
CallAfter([this] { wxGetApp().ShowDownNetPluginDlg(); });
|
CallAfter([this] { wxGetApp().ShowDownNetPluginDlg(); });
|
||||||
|
}
|
||||||
|
else if (command_str.compare("get_web_shortcut") == 0) {
|
||||||
|
if (root.get_child_optional("key_event") != boost::none) {
|
||||||
|
pt::ptree key_event_node = root.get_child("key_event");
|
||||||
|
auto keyCode = key_event_node.get<int>("key");
|
||||||
|
auto ctrlKey = key_event_node.get<bool>("ctrl");
|
||||||
|
auto shiftKey = key_event_node.get<bool>("shift");
|
||||||
|
auto cmdKey = key_event_node.get<bool>("cmd");
|
||||||
|
|
||||||
|
wxKeyEvent e(wxEVT_CHAR_HOOK);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
e.SetControlDown(cmdKey);
|
||||||
|
#else
|
||||||
|
e.SetControlDown(ctrlKey);
|
||||||
|
#endif
|
||||||
|
e.SetShiftDown(shiftKey);
|
||||||
|
e.m_keyCode = keyCode;
|
||||||
|
e.SetEventObject(mainframe);
|
||||||
|
wxPostEvent(mainframe, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,52 +238,52 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
// BBS
|
// BBS
|
||||||
wxAcceleratorEntry entries[13];
|
//wxAcceleratorEntry entries[13];
|
||||||
int index = 0;
|
//int index = 0;
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'N', wxID_HIGHEST + wxID_NEW);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'N', wxID_HIGHEST + wxID_NEW);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'O', wxID_HIGHEST + wxID_OPEN);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'O', wxID_HIGHEST + wxID_OPEN);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'S', wxID_HIGHEST + wxID_SAVE);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'S', wxID_HIGHEST + wxID_SAVE);
|
||||||
entries[index++].Set(wxACCEL_CTRL | wxACCEL_SHIFT, (int)'S', wxID_HIGHEST + wxID_SAVEAS);
|
//entries[index++].Set(wxACCEL_CTRL | wxACCEL_SHIFT, (int)'S', wxID_HIGHEST + wxID_SAVEAS);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'X', wxID_HIGHEST + wxID_CUT);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'X', wxID_HIGHEST + wxID_CUT);
|
||||||
//entries[index++].Set(wxACCEL_CTRL, (int)'I', wxID_HIGHEST + wxID_ADD);
|
////entries[index++].Set(wxACCEL_CTRL, (int)'I', wxID_HIGHEST + wxID_ADD);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'A', wxID_HIGHEST + wxID_SELECTALL);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'A', wxID_HIGHEST + wxID_SELECTALL);
|
||||||
entries[index++].Set(wxACCEL_NORMAL, (int)27 /* escape */, wxID_HIGHEST + wxID_CANCEL);
|
//entries[index++].Set(wxACCEL_NORMAL, (int)27 /* escape */, wxID_HIGHEST + wxID_CANCEL);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'Z', wxID_HIGHEST + wxID_UNDO);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'Z', wxID_HIGHEST + wxID_UNDO);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'Y', wxID_HIGHEST + wxID_REDO);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'Y', wxID_HIGHEST + wxID_REDO);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'C', wxID_HIGHEST + wxID_COPY);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'C', wxID_HIGHEST + wxID_COPY);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'V', wxID_HIGHEST + wxID_PASTE);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'V', wxID_HIGHEST + wxID_PASTE);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'P', wxID_HIGHEST + wxID_PREFERENCES);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'P', wxID_HIGHEST + wxID_PREFERENCES);
|
||||||
entries[index++].Set(wxACCEL_CTRL, (int)'I', wxID_HIGHEST + wxID_FILE6);
|
//entries[index++].Set(wxACCEL_CTRL, (int)'I', wxID_HIGHEST + wxID_FILE6);
|
||||||
wxAcceleratorTable accel(sizeof(entries) / sizeof(entries[0]), entries);
|
//wxAcceleratorTable accel(sizeof(entries) / sizeof(entries[0]), entries);
|
||||||
SetAcceleratorTable(accel);
|
//SetAcceleratorTable(accel);
|
||||||
|
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->new_project(); }, wxID_HIGHEST + wxID_NEW);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->new_project(); }, wxID_HIGHEST + wxID_NEW);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->load_project(); }, wxID_HIGHEST + wxID_OPEN);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->load_project(); }, wxID_HIGHEST + wxID_OPEN);
|
||||||
// BBS: close save project
|
//// BBS: close save project
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { if (m_plater) m_plater->save_project(); }, wxID_HIGHEST + wxID_SAVE);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { if (m_plater) m_plater->save_project(); }, wxID_HIGHEST + wxID_SAVE);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { if (m_plater) m_plater->save_project(true); }, wxID_HIGHEST + wxID_SAVEAS);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { if (m_plater) m_plater->save_project(true); }, wxID_HIGHEST + wxID_SAVEAS);
|
||||||
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { if (m_plater) m_plater->add_model(); }, wxID_HIGHEST + wxID_ADD);
|
////Bind(wxEVT_MENU, [this](wxCommandEvent&) { if (m_plater) m_plater->add_model(); }, wxID_HIGHEST + wxID_ADD);
|
||||||
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->remove_selected(); }, wxID_HIGHEST + wxID_DELETE);
|
////Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->remove_selected(); }, wxID_HIGHEST + wxID_DELETE);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) {
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) {
|
||||||
if (!can_add_models())
|
// if (!can_add_models())
|
||||||
return;
|
// return;
|
||||||
if (m_plater) {
|
// if (m_plater) {
|
||||||
m_plater->add_model();
|
// m_plater->add_model();
|
||||||
}
|
// }
|
||||||
}, wxID_HIGHEST + wxID_FILE6);
|
// }, wxID_HIGHEST + wxID_FILE6);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->select_all(); }, wxID_HIGHEST + wxID_SELECTALL);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->select_all(); }, wxID_HIGHEST + wxID_SELECTALL);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->deselect_all(); }, wxID_HIGHEST + wxID_CANCEL);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->deselect_all(); }, wxID_HIGHEST + wxID_CANCEL);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) {
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) {
|
||||||
if (m_plater->is_view3D_shown())
|
// if (m_plater->is_view3D_shown())
|
||||||
m_plater->undo();
|
// m_plater->undo();
|
||||||
}, wxID_HIGHEST + wxID_UNDO);
|
// }, wxID_HIGHEST + wxID_UNDO);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) {
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) {
|
||||||
if (m_plater->is_view3D_shown())
|
// if (m_plater->is_view3D_shown())
|
||||||
m_plater->redo();
|
// m_plater->redo();
|
||||||
}, wxID_HIGHEST + wxID_REDO);
|
// }, wxID_HIGHEST + wxID_REDO);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->copy_selection_to_clipboard(); }, wxID_HIGHEST + wxID_COPY);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->copy_selection_to_clipboard(); }, wxID_HIGHEST + wxID_COPY);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->paste_from_clipboard(); }, wxID_HIGHEST + wxID_PASTE);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->paste_from_clipboard(); }, wxID_HIGHEST + wxID_PASTE);
|
||||||
Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->cut_selection_to_clipboard(); }, wxID_HIGHEST + wxID_CUT);
|
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->cut_selection_to_clipboard(); }, wxID_HIGHEST + wxID_CUT);
|
||||||
Bind(wxEVT_SIZE, [this](wxSizeEvent&) {
|
Bind(wxEVT_SIZE, [this](wxSizeEvent&) {
|
||||||
BOOST_LOG_TRIVIAL(trace) << "mainframe: size changed, is maximized = " << this->IsMaximized();
|
BOOST_LOG_TRIVIAL(trace) << "mainframe: size changed, is maximized = " << this->IsMaximized();
|
||||||
if (this->IsMaximized()) {
|
if (this->IsMaximized()) {
|
||||||
|
@ -302,18 +302,18 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
||||||
});
|
});
|
||||||
Bind(EVT_SYNC_CLOUD_PRESET, &MainFrame::on_select_default_preset, this);
|
Bind(EVT_SYNC_CLOUD_PRESET, &MainFrame::on_select_default_preset, this);
|
||||||
|
|
||||||
Bind(wxEVT_MENU,
|
// Bind(wxEVT_MENU,
|
||||||
[this](wxCommandEvent&)
|
// [this](wxCommandEvent&)
|
||||||
{
|
// {
|
||||||
PreferencesDialog dlg(this);
|
// PreferencesDialog dlg(this);
|
||||||
dlg.ShowModal();
|
// dlg.ShowModal();
|
||||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
//#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||||
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
// if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||||
#else
|
//#else
|
||||||
if (dlg.seq_top_layer_only_changed())
|
// if (dlg.seq_top_layer_only_changed())
|
||||||
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
//#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||||
plater()->refresh_print();
|
// plater()->refresh_print();
|
||||||
}, wxID_HIGHEST + wxID_PREFERENCES);
|
// }, wxID_HIGHEST + wxID_PREFERENCES);
|
||||||
|
|
||||||
|
|
||||||
// set default tooltip timer in msec
|
// set default tooltip timer in msec
|
||||||
|
@ -474,6 +474,35 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
||||||
Slic3r::run_backup_ui_tasks();
|
Slic3r::run_backup_ui_tasks();
|
||||||
});
|
});
|
||||||
; }
|
; }
|
||||||
|
|
||||||
|
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent &evt) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
if (evt.CmdDown() && evt.GetKeyCode() == 'H') { this->Iconize(); return;}
|
||||||
|
if (evt.CmdDown() && evt.GetKeyCode() == 'Q') { wxPostEvent(this, wxCloseEvent(wxEVT_CLOSE_WINDOW)); return;}
|
||||||
|
#endif
|
||||||
|
if (evt.CmdDown() && evt.GetKeyCode() == 'N') { m_plater->new_project(); return;}
|
||||||
|
if (evt.CmdDown() && evt.GetKeyCode() == 'O') { m_plater->load_project(); return;}
|
||||||
|
if (evt.CmdDown() && evt.ShiftDown() && evt.GetKeyCode() == 'S') { if (m_plater) m_plater->save_project(true); return;}
|
||||||
|
else if (evt.CmdDown() && evt.GetKeyCode() == 'S') { if (m_plater) m_plater->save_project(); return;}
|
||||||
|
|
||||||
|
if (evt.CmdDown() && evt.GetKeyCode() == 'P') {
|
||||||
|
PreferencesDialog dlg(this);
|
||||||
|
dlg.ShowModal();
|
||||||
|
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||||
|
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||||
|
#else
|
||||||
|
if (dlg.seq_top_layer_only_changed())
|
||||||
|
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||||
|
plater()->refresh_print();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (evt.CmdDown() && evt.GetKeyCode() == 'I') {
|
||||||
|
if (!can_add_models()) return;
|
||||||
|
if (m_plater) { m_plater->add_model(); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
evt.Skip();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
|
|
Loading…
Reference in New Issue