From 5fd60e085ad8668e27203b1454a7fba5a03ef2e5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 6 Apr 2005 22:32:24 +0000 Subject: [PATCH] test EVT_TREE_ITEM_RIGHT_CLICK as well git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/treectrl/treetest.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index fdda0c22d2..4f3c978c76 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -137,14 +137,16 @@ BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl) 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) @@ -1171,7 +1173,9 @@ void MyTreeCtrl::OnItemMenu(wxTreeEvent& event) 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?) @@ -1219,6 +1223,18 @@ void MyTreeCtrl::ShowMenu(wxTreeItemId id, const wxPoint& pt) #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")); -- 2.45.2