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
This commit is contained in:
parent
f98488c8ca
commit
5fd60e085a
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user