mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-10-06 07:00:16 +08:00
Don't preselect popup menu items on macOS
Native macOS context menus are shown slightly to the right of the mouse cursor so that no item is initially selected. Other platforms do the same thing. Adjust placement position manually to ensure the same behavior when popping up the menu manually.
This commit is contained in:
+10
-1
@@ -866,9 +866,10 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
||||
bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||
{
|
||||
#ifndef __WXUNIVERSAL__
|
||||
const wxPoint mouse = wxGetMousePosition();
|
||||
|
||||
if ( x == wxDefaultCoord && y == wxDefaultCoord )
|
||||
{
|
||||
wxPoint mouse = wxGetMousePosition();
|
||||
x = mouse.x;
|
||||
y = mouse.y;
|
||||
}
|
||||
@@ -876,6 +877,14 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||
{
|
||||
ClientToScreen( &x , &y ) ;
|
||||
}
|
||||
|
||||
if ( x == mouse.x )
|
||||
{
|
||||
// move the menu just off the cursor so that no menu item is pre-selected,
|
||||
// for consistency with native popups and other platforms
|
||||
x += 1;
|
||||
}
|
||||
|
||||
menu->GetPeer()->PopUp(this, x, y);
|
||||
return true;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user