Using another API for popup menus on modal dialogs
Using popupMenuPositioningItem leads to several problems on modal dialogs - the validation and action callbacks are not used, thefore we revert in this situation to using the older API, see #549 and https://trac.wxwidgets.org/ticket/17459
This commit is contained in:
parent
102edb544d
commit
4d8c1fc890
@ -237,12 +237,40 @@ public :
|
||||
|
||||
virtual void PopUp( wxWindow *win, int x, int y ) wxOVERRIDE
|
||||
{
|
||||
win->ScreenToClient( &x , &y ) ;
|
||||
NSView *view = win->GetPeer()->GetWXWidget();
|
||||
// Turn off auto-enable; it caused popup menus inside of dialogs
|
||||
// to be entirely disabled.
|
||||
DisableAutoEnable();
|
||||
[m_osxMenu popUpMenuPositioningItem:nil atLocation:NSMakePoint(x, y) inView:view];
|
||||
|
||||
wxPoint screenPoint(x,y);
|
||||
NSPoint pointInView = wxToNSPoint(view, win->ScreenToClient( screenPoint ));
|
||||
|
||||
// action and validation methods are not called from macos for modal dialogs
|
||||
// when using popUpMenuPositioningItem therefore we fall back to the older method
|
||||
if ( wxDialog::OSXHasModalDialogsOpen() )
|
||||
{
|
||||
// we don't want plug-ins interfering
|
||||
m_osxMenu.allowsContextMenuPlugIns = NO;
|
||||
|
||||
wxTopLevelWindow* tlw = static_cast<wxTopLevelWindow*>(wxGetTopLevelParent(win));
|
||||
NSWindow* nsWindow = tlw->GetWXWindow();
|
||||
NSRect nsrect = NSZeroRect;
|
||||
nsrect.origin = wxToNSPoint( NULL, screenPoint );
|
||||
nsrect = [nsWindow convertRectFromScreen:nsrect];
|
||||
|
||||
NSEvent* rightClick = [NSEvent mouseEventWithType:NSRightMouseDown
|
||||
location:nsrect.origin
|
||||
modifierFlags:0
|
||||
timestamp:0
|
||||
windowNumber:[nsWindow windowNumber]
|
||||
context:nil
|
||||
eventNumber:0
|
||||
clickCount:1
|
||||
pressure:0];
|
||||
|
||||
[NSMenu popUpContextMenu:m_osxMenu withEvent:rightClick forView:view];
|
||||
}
|
||||
else
|
||||
{
|
||||
[m_osxMenu popUpMenuPositioningItem:nil atLocation:pointInView inView:view];
|
||||
}
|
||||
}
|
||||
|
||||
virtual void GetMenuBarDimensions(int &x, int &y, int &width, int &height) const wxOVERRIDE
|
||||
|
Loading…
Reference in New Issue
Block a user