Hi- I am using a wxTreeCtrl and setup the context menu in the frame; like this:
EVT_TREE_ITEM_MENU( ID_TREE_SPEC, Frame::OnTreeSpecItemMenu )
then when I do this:
void Frame::OnTreeSpecItemMenu( wxTreeEvent& event )
{
wxMenu* menu = new wxMenu;
menu->Append(wxID_OPEN, wxT("Open"));
PopupMenu(menu, event.GetPoint());
delete menu;
}
It all works as I would expect- ie poping up the menu when I right click on a tree item- but the menu is getting placed about 1 inch too high, instead of right next to the item the user right clicked on. I can't seem to find anything that would cause this- does anyone have any ideas?
BTW- i'm using wxDev-C++ with wxWidgets 2.6.1
Thanks for any help.
wxTreeCtrl context menu Topic is solved
-
- Earned some good credits
- Posts: 120
- Joined: Sun Aug 29, 2004 3:09 pm
- Location: Grenoble, France
- Contact:
You can use the
bool PopupMenu(wxMenu* menu, const wxPoint& pos = wxDefaultPosition)
with the wxDefaultPosition at third param, it will automatically place the menu at mouse position.
And if you really want to show your menu at the right side of the item, you can use wxTreeCtrl::GetBoundingRect [1] to retrieve it position.
1 : http://www.wxwidgets.org/manuals/2.6.2/ ... etitemrect
bool PopupMenu(wxMenu* menu, const wxPoint& pos = wxDefaultPosition)
with the wxDefaultPosition at third param, it will automatically place the menu at mouse position.
And if you really want to show your menu at the right side of the item, you can use wxTreeCtrl::GetBoundingRect [1] to retrieve it position.
1 : http://www.wxwidgets.org/manuals/2.6.2/ ... etitemrect
What is little and green, witch go up and down ??
Yoda playing with the force.
Yoda playing with the force.