Fixed a bug where the device interface failed to render by pressing alt button

This commit is contained in:
sunsets
2024-04-01 15:16:47 +08:00
parent 3a99562743
commit 9b04886c3a
3 changed files with 57 additions and 13 deletions

View File

@@ -2178,6 +2178,8 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
#if defined(__WIN32__) || defined(__WXMAC__) #if defined(__WIN32__) || defined(__WXMAC__)
m_printer_view->ResumeButton(); m_printer_view->ResumeButton();
//B63
m_printer_view->SetFocus();
#endif #endif

View File

@@ -25,13 +25,12 @@ namespace Slic3r {
namespace GUI { namespace GUI {
wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter) //wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter)
EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave) // EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave)
//EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown) // // EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown)
// EVT_LEFT_UP(MachineListButton::OnMouseLeftUp) // // EVT_LEFT_UP(MachineListButton::OnMouseLeftUp)
EVT_SET_FOCUS(MachineListButton::OnSetFocus) // EVT_SET_FOCUS(MachineListButton::OnSetFocus) EVT_KILL_FOCUS(MachineListButton::OnKillFocus) EVT_KEY_DOWN(MachineListButton::OnKeyDown)
EVT_KILL_FOCUS(MachineListButton::OnKillFocus) EVT_KEY_DOWN(MachineListButton::OnKeyDown) EVT_KEY_UP(MachineListButton::OnKeyUp) // EVT_KEY_UP(MachineListButton::OnKeyUp) wxEND_EVENT_TABLE()
wxEND_EVENT_TABLE()
//B45 //B45
@@ -196,7 +195,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
//MachineListButton *add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, //MachineListButton *add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
// wxDefaultValidator, wxButtonNameStr); // wxDefaultValidator, wxButtonNameStr);
//wxButton *add_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); //wxButton *add_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
MachineListButton *add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, //B63
add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
wxDefaultValidator, wxButtonNameStr); wxDefaultValidator, wxButtonNameStr);
#if defined(__WIN32__) || defined(__WXMAC__) #if defined(__WIN32__) || defined(__WXMAC__)
add_button->SetBackgroundColour(wxColour(30, 30, 21)); add_button->SetBackgroundColour(wxColour(30, 30, 21));
@@ -211,7 +211,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
//wxButton *delete_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); //wxButton *delete_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
MachineListButton *delete_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, //B63
delete_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
wxDefaultValidator, wxButtonNameStr); wxDefaultValidator, wxButtonNameStr);
#if defined(__WIN32__) || defined(__WXMAC__) #if defined(__WIN32__) || defined(__WXMAC__)
delete_button->SetBackgroundColour(wxColour(30, 30, 21)); delete_button->SetBackgroundColour(wxColour(30, 30, 21));
@@ -224,7 +225,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
buttonsizer->Add(delete_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2)); buttonsizer->Add(delete_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
delete_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnDeleteButtonClick, this); delete_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnDeleteButtonClick, this);
MachineListButton *edit_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, //B63
edit_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
wxDefaultValidator, wxButtonNameStr); wxDefaultValidator, wxButtonNameStr);
//wxButton *edit_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); //wxButton *edit_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
#if defined(__WIN32__) || defined(__WXMAC__) #if defined(__WIN32__) || defined(__WXMAC__)
@@ -238,7 +240,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
buttonsizer->Add(edit_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2)); buttonsizer->Add(edit_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
edit_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnEditButtonClick, this); edit_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnEditButtonClick, this);
MachineListButton *refresh_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, refresh_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize,
wxBU_LEFT, wxDefaultValidator, wxButtonNameStr); wxBU_LEFT, wxDefaultValidator, wxButtonNameStr);
//wxButton *refresh_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); //wxButton *refresh_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
#if defined(__WIN32__) || defined(__WXMAC__) #if defined(__WIN32__) || defined(__WXMAC__)
@@ -387,11 +389,28 @@ void PrinterWebView::AddButton(const wxString & devi
#else #else
customButton->SetSize(wxSize(200, -1)); customButton->SetSize(wxSize(200, -1));
#endif #endif
//B63
customButton->Bind(wxEVT_KEY_UP, &PrinterWebView::OnKeyUp, this);
leftsizer->Add(customButton, wxSizerFlags().Border(wxALL, 1).Expand()); leftsizer->Add(customButton, wxSizerFlags().Border(wxALL, 1).Expand());
leftsizer->Layout(); leftsizer->Layout();
m_buttons.push_back(customButton); m_buttons.push_back(customButton);
} }
//B63
void PrinterWebView::RefreshButton()
{
if (m_buttons.empty()) {
BOOST_LOG_TRIVIAL(info) << " empty";
} else {
for (MachineListButton *button : m_buttons) {
button->Refresh();
}
add_button->Refresh();
delete_button->Refresh();
edit_button->Refresh();
refresh_button->Refresh();
}
}
//B45 //B45
void PrinterWebView::PauseButton() void PrinterWebView::PauseButton()
@@ -781,6 +800,13 @@ void PrinterWebView::OnScroll(wxScrollWinEvent &event)
event.Skip(); event.Skip();
} }
//B63
void PrinterWebView::OnKeyUp(wxKeyEvent &event)
{
event.Skip();
RefreshButton();
}
//B45 //B45
void PrinterWebView::load_url(wxString& url) void PrinterWebView::load_url(wxString& url)
{ {

View File

@@ -71,6 +71,13 @@ public:
else else
SetBackgroundColour(wxColour(67, 67, 71)); SetBackgroundColour(wxColour(67, 67, 71));
#endif #endif
Bind(wxEVT_PAINT, &MachineListButton::OnPaint, this);
Bind(wxEVT_ENTER_WINDOW, &MachineListButton::OnMouseEnter, this);
Bind(wxEVT_LEAVE_WINDOW, &MachineListButton::OnMouseLeave, this);
Bind(wxEVT_SET_FOCUS, &MachineListButton::OnSetFocus, this);
Bind(wxEVT_KILL_FOCUS, &MachineListButton::OnKillFocus, this);
Bind(wxEVT_KEY_DOWN, &MachineListButton::OnKeyDown, this);
//Bind(wxEVT_KEY_UP, &MachineListButton::OnKeyUp, this);
} }
void SetLabel(const wxString &fullname) { full_label = fullname; } void SetLabel(const wxString &fullname) { full_label = fullname; }
@@ -159,7 +166,7 @@ public:
void OnKeyUp(wxKeyEvent &event); void OnKeyUp(wxKeyEvent &event);
void OnMouseEnter(wxMouseEvent &event); void OnMouseEnter(wxMouseEvent &event);
void OnMouseLeave(wxMouseEvent &event); void OnMouseLeave(wxMouseEvent &event);
void OnMouseLeftDown(wxMouseEvent &event); //void OnMouseLeftDown(wxMouseEvent &event);
//void OnMouseLeftUp(wxMouseEvent &event); //void OnMouseLeftUp(wxMouseEvent &event);
//void OnClickHandler(wxCommandEvent &event); //void OnClickHandler(wxCommandEvent &event);
void SetStatusThread(std::thread thread) { m_statusThread = std::move(thread); } void SetStatusThread(std::thread thread) { m_statusThread = std::move(thread); }
@@ -228,7 +235,7 @@ private:
std::function<void(wxMouseEvent &)> m_handlerl; std::function<void(wxMouseEvent &)> m_handlerl;
//B59 //B59
bool m_is_QIDI; bool m_is_QIDI;
wxDECLARE_EVENT_TABLE(); //wxDECLARE_EVENT_TABLE();
}; };
@@ -258,6 +265,8 @@ public:
void OnScroll(wxScrollWinEvent &event); void OnScroll(wxScrollWinEvent &event);
void OnScrollup(wxScrollWinEvent &event); void OnScrollup(wxScrollWinEvent &event);
void OnScrolldown(wxScrollWinEvent &event); void OnScrolldown(wxScrollWinEvent &event);
//B63
void OnKeyUp(wxKeyEvent &event);
void SetUpdateHandler(const std::function<void(wxCommandEvent &)> &handler) { m_handlerl = handler; } void SetUpdateHandler(const std::function<void(wxCommandEvent &)> &handler) { m_handlerl = handler; }
void SetDeleteHandler(const std::function<void(wxCommandEvent &)> &handler) { m_delete_handlerl = handler; } void SetDeleteHandler(const std::function<void(wxCommandEvent &)> &handler) { m_delete_handlerl = handler; }
@@ -280,6 +289,8 @@ public:
void StopAllThread(); void StopAllThread();
void UnSelectedButton(); void UnSelectedButton();
//B63
void RefreshButton();
std::vector<MachineListButton *> GetButton() { return m_buttons; }; std::vector<MachineListButton *> GetButton() { return m_buttons; };
private: private:
@@ -306,6 +317,11 @@ private:
wxWebView* m_browser; wxWebView* m_browser;
long m_zoomFactor; long m_zoomFactor;
//B63
MachineListButton *add_button;
MachineListButton *delete_button;
MachineListButton *edit_button;
MachineListButton *refresh_button;
// DECLARE_EVENT_TABLE() // DECLARE_EVENT_TABLE()
}; };