mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 02:41:58 +08:00
TextInput: Added possibility to set function on DropDown icon
This commit is contained in:
parent
a336a2c379
commit
e92304c6eb
@ -533,6 +533,8 @@ void OptionsSearcher::set_search_input(TextInput* input_ctrl)
|
||||
event.Skip();
|
||||
update_dialog_position();
|
||||
});
|
||||
|
||||
search_input->SetOnDropDownIcon([](){ GUI::wxGetApp().show_search_dialog(); });
|
||||
}
|
||||
|
||||
void OptionsSearcher::add_key(const std::string& opt_key, Preset::Type type, const wxString& group, const wxString& category)
|
||||
|
@ -86,6 +86,12 @@ void TextInput::Create(wxWindow * parent,
|
||||
|
||||
if (!icon.IsEmpty()) {
|
||||
this->drop_down_icon = ScalableBitmap(this, icon.ToStdString(), 16);
|
||||
this->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event) {
|
||||
const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
|
||||
if (OnClickDropDownIcon && dd_icon_rect.Contains(pos))
|
||||
OnClickDropDownIcon();
|
||||
event.Skip();
|
||||
});
|
||||
}
|
||||
messureSize();
|
||||
}
|
||||
@ -295,6 +301,7 @@ void TextInput::render(wxDC& dc)
|
||||
wxSize szIcon = drop_down_icon.GetSize();
|
||||
pt_r.x -= szIcon.x + 2;
|
||||
pt_r.y = (size.y - szIcon.y) / 2;
|
||||
dd_icon_rect = wxRect(pt_r, szIcon);
|
||||
dc.DrawBitmap(drop_down_icon.get_bitmap(), pt_r);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,9 @@ class TextInput : public wxNavigationEnabled<StaticBox>
|
||||
static const int TextInputWidth = 200;
|
||||
static const int TextInputHeight = 50;
|
||||
|
||||
wxRect dd_icon_rect;
|
||||
std::function<void()> OnClickDropDownIcon{ nullptr };
|
||||
|
||||
public:
|
||||
TextInput();
|
||||
|
||||
@ -73,6 +76,8 @@ public:
|
||||
|
||||
void SysColorsChanged();
|
||||
|
||||
void SetOnDropDownIcon(std::function<void()> click_drop_down_icon_fn) { OnClickDropDownIcon = click_drop_down_icon_fn; }
|
||||
|
||||
protected:
|
||||
virtual void OnEdit() {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user