EVT_TREE_ITEM_COLLAPSED(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsed)
EVT_TREE_ITEM_COLLAPSING(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsing)
- EVT_CONTEXT_MENU(MyTreeCtrl::OnContextMenu)
- EVT_TREE_ITEM_MENU(TreeTest_Ctrl, MyTreeCtrl::OnItemMenu)
-
EVT_TREE_SEL_CHANGED(TreeTest_Ctrl, MyTreeCtrl::OnSelChanged)
EVT_TREE_SEL_CHANGING(TreeTest_Ctrl, MyTreeCtrl::OnSelChanging)
EVT_TREE_KEY_DOWN(TreeTest_Ctrl, MyTreeCtrl::OnTreeKeyDown)
EVT_TREE_ITEM_ACTIVATED(TreeTest_Ctrl, MyTreeCtrl::OnItemActivated)
+ // so many differents ways to handle right mouse button clicks...
+ EVT_CONTEXT_MENU(MyTreeCtrl::OnContextMenu)
+ EVT_TREE_ITEM_MENU(TreeTest_Ctrl, MyTreeCtrl::OnItemMenu)
+ EVT_TREE_ITEM_RIGHT_CLICK(TreeTest_Ctrl, MyTreeCtrl::OnItemRClick)
+
EVT_RIGHT_DOWN(MyTreeCtrl::OnRMouseDown)
EVT_RIGHT_UP(MyTreeCtrl::OnRMouseUp)
EVT_RIGHT_DCLICK(MyTreeCtrl::OnRMouseDClick)
void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
{
wxPoint pt = event.GetPosition();
- wxTreeItemId item = GetSelection();
+ wxTreeItemId item;
+ if ( !HasFlag(wxTR_MULTIPLE) )
+ item = GetSelection();
wxLogMessage(wxT("OnContextMenu at screen coords (%i, %i)"), pt.x, pt.y);
// check if event was generated by keyboard (MSW-specific?)
#endif // wxUSE_MENUS
}
+void MyTreeCtrl::OnItemRClick(wxTreeEvent& event)
+{
+ wxTreeItemId itemId = event.GetItem();
+ MyTreeItemData *item = itemId.IsOk() ? (MyTreeItemData *)GetItemData(itemId)
+ : NULL;
+
+ wxLogMessage(wxT("Item \"%s\" right clicked"), item ? item->GetDesc()
+ : _T(""));
+
+ event.Skip();
+}
+
void MyTreeCtrl::OnRMouseDown(wxMouseEvent& event)
{
wxLogMessage(wxT("Right mouse button down"));