Set list manipulation action on LeftButton too

Note: Doesn't work under OSX
This commit is contained in:
YuSanka 2019-08-20 13:01:01 +02:00
parent 7706a5be3e
commit 52c24a1662
2 changed files with 31 additions and 15 deletions

View File

@ -134,7 +134,11 @@ ObjectList::ObjectList(wxWindow* parent) :
selection_changed(); selection_changed();
#ifndef __WXMSW__ #ifndef __WXMSW__
set_tooltip_for_item(get_mouse_position_in_control()); set_tooltip_for_item(get_mouse_position_in_control());
#endif //__WXMSW__ #endif //__WXMSW__
#ifndef __WXOSX__
list_manipulation();
#endif //__WXOSX__
}); });
#ifdef __WXOSX__ #ifdef __WXOSX__
@ -169,7 +173,7 @@ ObjectList::ObjectList(wxWindow* parent) :
#ifdef __WXMSW__ #ifdef __WXMSW__
GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) { GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) {
set_tooltip_for_item(/*event.GetPosition()*/get_mouse_position_in_control()); set_tooltip_for_item(get_mouse_position_in_control());
event.Skip(); event.Skip();
}); });
#endif //__WXMSW__ #endif //__WXMSW__
@ -330,28 +334,34 @@ void ObjectList::set_tooltip_for_item(const wxPoint& pt)
* Just this->SetToolTip(tooltip) => has no effect. * Just this->SetToolTip(tooltip) => has no effect.
*/ */
if (!item) if (!item || GetSelectedItemsCount() > 1)
{ {
GetMainWindow()->SetToolTip(""); // hide tooltip GetMainWindow()->SetToolTip(""); // hide tooltip
return; return;
} }
if (col->GetTitle() == _(L("Editing")) && GetSelectedItemsCount()<2) wxString tooltip = "";
GetMainWindow()->SetToolTip(_(L("Right button click the icon to change the object settings")));
else if (col->GetTitle() == _("Name")) if (col->GetTitle() == _(L("Editing")))
{ #ifdef __WXOSX__
#ifdef __WXMSW__ tooltip = _(L("Right button click the icon to change the object settings"));
if (pt.x < 2 * wxGetApp().em_unit() || pt.x > 4 * wxGetApp().em_unit()) { #else
GetMainWindow()->SetToolTip(""); // hide tooltip tooltip = _(L("Click the icon to change the object settings"));
return;
}
#endif //__WXMSW__ #endif //__WXMSW__
else if (col->GetTitle() == " ")
#ifdef __WXOSX__
tooltip = _(L("Right button click the icon to change the object printable property"));
#else
tooltip = _(L("Click the icon to change the object printable property"));
#endif //__WXMSW__
else if (col->GetTitle() == _("Name") && (pt.x >= 2 * wxGetApp().em_unit() && pt.x <= 4 * wxGetApp().em_unit()))
{
int obj_idx, vol_idx; int obj_idx, vol_idx;
get_selected_item_indexes(obj_idx, vol_idx, item); get_selected_item_indexes(obj_idx, vol_idx, item);
GetMainWindow()->SetToolTip(get_mesh_errors_list(obj_idx, vol_idx)); tooltip = get_mesh_errors_list(obj_idx, vol_idx);
} }
else
GetMainWindow()->SetToolTip(""); // hide tooltip GetMainWindow()->SetToolTip(tooltip);
} }
wxPoint ObjectList::get_mouse_position_in_control() wxPoint ObjectList::get_mouse_position_in_control()
@ -744,6 +754,11 @@ void ObjectList::OnChar(wxKeyEvent& event)
#endif /* __WXOSX__ */ #endif /* __WXOSX__ */
void ObjectList::OnContextMenu(wxDataViewEvent&) void ObjectList::OnContextMenu(wxDataViewEvent&)
{
list_manipulation();
}
void ObjectList::list_manipulation()
{ {
wxDataViewItem item; wxDataViewItem item;
wxDataViewColumn* col; wxDataViewColumn* col;

View File

@ -358,6 +358,7 @@ private:
// void OnChar(wxKeyEvent& event); // void OnChar(wxKeyEvent& event);
#endif /* __WXOSX__ */ #endif /* __WXOSX__ */
void OnContextMenu(wxDataViewEvent &event); void OnContextMenu(wxDataViewEvent &event);
void list_manipulation();
void OnBeginDrag(wxDataViewEvent &event); void OnBeginDrag(wxDataViewEvent &event);
void OnDropPossible(wxDataViewEvent &event); void OnDropPossible(wxDataViewEvent &event);