Cocoa: LM_CONTEXTMENU is sent when the right mouse button is released instead of being pressed

1. consistent with Win32
2. avoids the problem that is easy to occur in APP, because the context menu pops up after the APP receives LM_CONTEXTMENU, which will lose the LM_MOUSEUP event. For example, in IDE Form Designer, if you right-click to pop up the context menu, after closing the context menu, the Designer is still in the MouseDown state by mistake
This commit is contained in:
rich2014 2024-05-29 21:37:53 +08:00
parent f064cbaf78
commit 728ef54055

View File

@ -935,9 +935,9 @@ function isContextMenuEvent(event: NSEvent): Boolean;
begin
Result := Assigned(event)
and (
(Event.type_ = NSRightMouseDown)
(Event.type_ = NSRightMouseUp)
or(
(Event.type_ = NSLeftMouseDown)
(Event.type_ = NSLeftMouseUp)
and (event.modifierFlags and NSControlKeyMask <> 0)
and (event.clickCount = 1)
)
@ -1035,14 +1035,6 @@ begin
NotifyApplicationUserInput(Target, Msg.Msg);
DeliverMessage(Msg);
// TODO: Check if Cocoa has special context menu check event
// it does (menuForEvent:), but it doesn't work all the time
// http://sound-of-silence.com/?article=20150923
if (GetTarget is TControl) and isContextMenuEvent(Event) then
begin
SendContextMenu(Event, menuHandled);
if menuHandled then Result := true;
end;
end;
NSLeftMouseUp,
NSRightMouseUp,
@ -1058,6 +1050,15 @@ begin
NotifyApplicationUserInput(Target, Msg.Msg);
DeliverMessage(Msg);
// TODO: Check if Cocoa has special context menu check event
// it does (menuForEvent:), but it doesn't work all the time
// http://sound-of-silence.com/?article=20150923
if (GetTarget is TControl) and isContextMenuEvent(Event) then
begin
SendContextMenu(Event, menuHandled);
if menuHandled then Result := true;
end;
end;
end;