wxTreeCtrl - why events are always from selected ? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
saifcoder
Experienced Solver
Experienced Solver
Posts: 80
Joined: Thu Nov 16, 2017 9:32 pm

wxTreeCtrl - why events are always from selected ?

Post by saifcoder »

1 - just create a sample wxTreeCtrl control
2 - create two items
3 - then select item 1 (left click)
4 - right click on item 2
event come from item 1

Code: Select all

EVT_TREE_ITEM_MENU or EVT_TREE_ITEM_RIGHT_CLICK
GetFocusedItem() or GetSelection()

always return item 1, but we click right on item 2.
User avatar
saifcoder
Experienced Solver
Experienced Solver
Posts: 80
Joined: Thu Nov 16, 2017 9:32 pm

Re: wxTreeCtrl - why events are always from selected ?

Post by saifcoder »

fixed.

dont use GetFocusedItem() or GetSelection() to get ID of non focused item, but use

Code: Select all

event.GetItem();
Post Reply