I am using the following code to create context menu. It works fine but the issue is, it does not appear at the mouse position. Instead, it appears 30 pixel ablove from the mouse's Y value.
Code: Select all
void MyFrame::OnContextMenu( wxContextMenuEvent& event )
{
wxPoint point = event.GetPosition();
// If from keyboard
if( point.x == -1 && point.y == -1 )
{
wxSize size = GetSize();
point.x = size.x / 2;
point.y = size.y / 2;
}
else
{
point = ScreenToClient( point );
}
wxMenu menu;
menu.Append( wxID_ANY, _T( "Item-1" ) );
menu.Append( wxID_ANY, _T( "Item-2" ) );
menu.Append( wxID_ANY, _T( "Item-3" ) );
PopupMenu( &menu, point.x, point.y );
}
I am having wxFrame within that wxSashWindow. The right side sash window contains openGL like window. The context menu does not appear while we right click at opnGL window.
I have attached sample image.
Any suggestions, welcome.