mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Implemented OnMouseMove and OnMouseClick for PopupSearchList
This commit is contained in:
parent
cd13356b6d
commit
dcdafb6208
2 changed files with 31 additions and 15 deletions
|
@ -482,8 +482,8 @@ SearchCtrl::SearchCtrl(wxWindow* parent)
|
||||||
|
|
||||||
box_sizer->Add(comboCtrl, 0, wxALIGN_CENTER_VERTICAL);
|
box_sizer->Add(comboCtrl, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
popupListBox->Bind(wxEVT_LISTBOX, &SearchCtrl::OnSelect, this);
|
// popupListBox->Bind(wxEVT_LEFT_DOWN, &SearchCtrl::OnLeftDownInPopup, this);
|
||||||
popupListBox->Bind(wxEVT_LEFT_DOWN, &SearchCtrl::OnLeftDownInPopup, this);
|
popupListBox->Bind(wxEVT_LISTBOX, &SearchCtrl::OnSelect, this);
|
||||||
|
|
||||||
comboCtrl->Bind(wxEVT_TEXT, &SearchCtrl::OnInputText, this);
|
comboCtrl->Bind(wxEVT_TEXT, &SearchCtrl::OnInputText, this);
|
||||||
comboCtrl->Bind(wxEVT_TEXT_ENTER, &SearchCtrl::PopupList, this);
|
comboCtrl->Bind(wxEVT_TEXT_ENTER, &SearchCtrl::PopupList, this);
|
||||||
|
@ -559,18 +559,21 @@ void SearchCtrl::msw_rescale()
|
||||||
comboCtrl->SetButtonBitmaps(create_scaled_bitmap("search"));
|
comboCtrl->SetButtonBitmaps(create_scaled_bitmap("search"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchCtrl::select(int selection)
|
||||||
|
{
|
||||||
|
if (selection < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prevent_update = true;
|
||||||
|
wxGetApp().sidebar().jump_to_option(selection);
|
||||||
|
prevent_update = false;
|
||||||
|
|
||||||
|
// comboCtrl->Dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
void SearchCtrl::OnSelect(wxCommandEvent& event)
|
void SearchCtrl::OnSelect(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
prevent_update = true;
|
select(event.GetSelection());
|
||||||
|
|
||||||
int selection = event.GetSelection();
|
|
||||||
if (selection >= 0)
|
|
||||||
wxGetApp().sidebar().jump_to_option(selection);
|
|
||||||
|
|
||||||
prevent_update = false;
|
|
||||||
|
|
||||||
comboCtrl->Dismiss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchCtrl::update_list(std::vector<SearchOptions::Filter>& filters)
|
void SearchCtrl::update_list(std::vector<SearchOptions::Filter>& filters)
|
||||||
|
@ -596,7 +599,7 @@ void SearchCtrl::OnLeftUpInTextCtrl(wxEvent &event)
|
||||||
void SearchCtrl::OnLeftDownInPopup(wxEvent &event)
|
void SearchCtrl::OnLeftDownInPopup(wxEvent &event)
|
||||||
{
|
{
|
||||||
wxPoint pt = wxGetMousePosition() - popupListBox->GetScreenPosition();
|
wxPoint pt = wxGetMousePosition() - popupListBox->GetScreenPosition();
|
||||||
int selected_item = popupListBox->HitTest(pt);
|
select(popupListBox->HitTest(pt));
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,11 @@ class SearchComboPopup : public wxListBox, public wxComboPopup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Initialize member variables
|
// Initialize member variables
|
||||||
virtual void Init(){}
|
virtual void Init()
|
||||||
|
{
|
||||||
|
this->Bind(wxEVT_MOTION, &SearchComboPopup::OnMouseMove, this);
|
||||||
|
this->Bind(wxEVT_LEFT_UP, &SearchComboPopup::OnMouseClick, this);
|
||||||
|
}
|
||||||
|
|
||||||
// Create popup control
|
// Create popup control
|
||||||
virtual bool Create(wxWindow* parent)
|
virtual bool Create(wxWindow* parent)
|
||||||
|
@ -184,12 +188,20 @@ public:
|
||||||
// Do mouse hot-tracking (which is typical in list popups)
|
// Do mouse hot-tracking (which is typical in list popups)
|
||||||
void OnMouseMove(wxMouseEvent& event)
|
void OnMouseMove(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
// TODO: Move selection to cursor
|
wxPoint pt = wxGetMousePosition() - this->GetScreenPosition();
|
||||||
|
int selection = this->HitTest(pt);
|
||||||
|
wxListBox::Select(selection);
|
||||||
}
|
}
|
||||||
// On mouse left up, set the value and close the popup
|
// On mouse left up, set the value and close the popup
|
||||||
void OnMouseClick(wxMouseEvent& WXUNUSED(event))
|
void OnMouseClick(wxMouseEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
// TODO: Send event as well
|
int selection = wxListBox::GetSelection();
|
||||||
|
SetSelection(wxNOT_FOUND);
|
||||||
|
wxCommandEvent event(wxEVT_LISTBOX, GetId());
|
||||||
|
event.SetInt(selection);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
ProcessEvent(event);
|
||||||
|
|
||||||
Dismiss();
|
Dismiss();
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
@ -226,6 +238,7 @@ public:
|
||||||
|
|
||||||
void set_search_line(const std::string& search_line);
|
void set_search_line(const std::string& search_line);
|
||||||
void msw_rescale();
|
void msw_rescale();
|
||||||
|
void select(int selection);
|
||||||
|
|
||||||
void update_list(std::vector<SearchOptions::Filter>& filters);
|
void update_list(std::vector<SearchOptions::Filter>& filters);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue