diff --git a/resources/web/guide/23/index.html b/resources/web/guide/23/index.html index cffa328c14..fcafcff7b1 100644 --- a/resources/web/guide/23/index.html +++ b/resources/web/guide/23/index.html @@ -146,4 +146,22 @@ + diff --git a/resources/web/guide/24/index.html b/resources/web/guide/24/index.html index 6349a09957..6f77f8e09b 100644 --- a/resources/web/guide/24/index.html +++ b/resources/web/guide/24/index.html @@ -99,4 +99,17 @@ + diff --git a/resources/web/guide/js/common.js b/resources/web/guide/js/common.js index e69de29bb2..b0aafeaf37 100644 --- a/resources/web/guide/js/common.js +++ b/resources/web/guide/js/common.js @@ -0,0 +1,21 @@ +function ClosePage() { + var tSend = {}; + tSend['sequence_id'] = Math.round(new Date() / 1000); + tSend['command'] = "close_page"; + SendWXMessage(JSON.stringify(tSend)); +} + +document.onkeydown = function (event) { + var e = event || window.event || arguments.callee.caller.arguments[0]; + + if (window.event) { + try { e.keyCode = 0; } catch (e) { } + e.returnValue = false; + } +}; + +window.addEventListener('wheel', function (event) { + if (event.ctrlKey === true || event.metaKey) { + event.preventDefault(); + } +}, { passive: false }); diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index a3e239d1cc..6daa308c28 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -189,6 +189,19 @@ public: event.Skip(); on_sys_color_changed(); }); + + if (std::is_same::value) { + this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) { + if (e.GetKeyCode() == WXK_ESCAPE) { + //if (this->IsModal()) + // this->EndModal(wxID_CANCEL); + //else + this->Close(); + } + else + e.Skip(); + }); + } } virtual ~DPIAware() {} diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 655c33f978..f544bb61ad 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -77,7 +77,18 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style) //int screenwidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X, NULL); //int MaxY = (screenheight - pSize.y) > 0 ? (screenheight - pSize.y) / 2 : 0; //MoveWindow(this->m_hWnd, (screenwidth - pSize.x) / 2, MaxY, pSize.x, pSize.y, TRUE); - +#ifdef __WXMSW__ + this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) { + if ((m_page == BBL_FILAMENT_ONLY || m_page == BBL_MODELS_ONLY) && e.GetKeyCode() == WXK_ESCAPE) { + if (this->IsModal()) + this->EndModal(wxID_CANCEL); + else + this->Close(); + } + else + e.Skip(); + }); +#endif // Connect the webview events Bind(wxEVT_WEBVIEW_NAVIGATING, &GuideFrame::OnNavigationRequest, this, m_browser->GetId()); Bind(wxEVT_WEBVIEW_NAVIGATED, &GuideFrame::OnNavigationComplete, this, m_browser->GetId()); @@ -121,6 +132,7 @@ void GuideFrame::load_url(wxString &url) wxString GuideFrame::SetStartPage(GuidePage startpage, bool load) { + m_page = startpage; BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(" enter, load=%1%, start_page=%2%")%load%int(startpage); //wxLogMessage("GUIDE: webpage_1 %s", (boost::filesystem::path(resources_dir()) / "web\\guide\\1\\index.html").make_preferred().string().c_str() ); wxString TargetUrl = from_u8( (boost::filesystem::path(resources_dir()) / "web/guide/1/index.html").make_preferred().string() ); @@ -274,7 +286,9 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) json j = json::parse(strInput); wxString strCmd = j["command"]; - + if (strCmd == "close_page") { + this->EndModal(wxID_CANCEL); + } if (strCmd == "user_clause") { wxString strAction = j["data"]["action"]; diff --git a/src/slic3r/GUI/WebGuideDialog.hpp b/src/slic3r/GUI/WebGuideDialog.hpp index 83d7799dbf..de7727663c 100644 --- a/src/slic3r/GUI/WebGuideDialog.hpp +++ b/src/slic3r/GUI/WebGuideDialog.hpp @@ -47,7 +47,7 @@ public: BBL_FILAMENTS, BBL_FILAMENT_ONLY, BBL_MODELS_ONLY - }; + }m_page; //Web Function void load_url(wxString &url); diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 4a7b7d5a80..b7f65e4c1a 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -172,6 +172,16 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, c this->FindWindowById(wxID_RESET, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { m_panel_wiping->calc_flushing_volumes(); }); } this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); }); + this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) { + if (e.GetKeyCode() == WXK_ESCAPE) { + if (this->IsModal()) + this->EndModal(wxID_CANCEL); + else + this->Close(); + } + else + e.Skip(); + }); } void WipingPanel::create_panels(wxWindow* parent, const int num) {