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:
@@ -237,12 +237,40 @@ public :
|
|||||||
|
|
||||||
virtual void PopUp( wxWindow *win, int x, int y ) wxOVERRIDE
|
virtual void PopUp( wxWindow *win, int x, int y ) wxOVERRIDE
|
||||||
{
|
{
|
||||||
win->ScreenToClient( &x , &y ) ;
|
|
||||||
NSView *view = win->GetPeer()->GetWXWidget();
|
NSView *view = win->GetPeer()->GetWXWidget();
|
||||||
// Turn off auto-enable; it caused popup menus inside of dialogs
|
|
||||||
// to be entirely disabled.
|
wxPoint screenPoint(x,y);
|
||||||
DisableAutoEnable();
|
NSPoint pointInView = wxToNSPoint(view, win->ScreenToClient( screenPoint ));
|
||||||
[m_osxMenu popUpMenuPositioningItem:nil atLocation:NSMakePoint(x, y) inView:view];
|
|
||||||
|
// 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
|
virtual void GetMenuBarDimensions(int &x, int &y, int &width, int &height) const wxOVERRIDE
|
||||||
|
Reference in New Issue
Block a user