mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 02:57:17 +01:00
cocoa: additional code to handle unassigning of trayicon menu
git-svn-id: trunk@59755 -
This commit is contained in:
parent
360bfc74b1
commit
3b93e700c5
@ -4,7 +4,7 @@ type
|
||||
|
||||
{ TCocoaStatusItemHandle }
|
||||
|
||||
TCocoaStatusItemHandle = objcclass(NSObject)
|
||||
TCocoaStatusItemHandle = objcclass(NSObject, NSMenuDelegateProtocol)
|
||||
public
|
||||
{ Fields }
|
||||
statusitem: NSStatusItem;
|
||||
@ -12,6 +12,7 @@ type
|
||||
{ Methods }
|
||||
procedure lclAction(sender: id); message 'lclAction:';
|
||||
procedure lclSetTrayIcon(ATrayIcon: TCustomTrayIcon); message 'lclSetTrayIcon:';
|
||||
procedure menuWillOpen(menu: NSMenu); message 'menuWillOpen:';
|
||||
end;
|
||||
|
||||
{ TCocoaStatusItemHandle }
|
||||
@ -41,10 +42,25 @@ begin
|
||||
if (ATrayIcon.PopUpMenu <> nil) then
|
||||
begin
|
||||
ATrayIcon.PopUpMenu.HandleNeeded();
|
||||
//ATrayIcon.PopUpMenu.
|
||||
if Assigned(statusitem.menu) and (statusitem.menu.delegate = NSMenuDelegateProtocol(self)) then
|
||||
statusitem.menu.setDelegate(nil);
|
||||
|
||||
statusitem.setMenu(TCocoaMenu(ATrayIcon.PopUpMenu.Handle));
|
||||
|
||||
TCocoaMenu(ATrayIcon.PopUpMenu.Handle).setDelegate( self);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaStatusItemHandle.menuWillOpen(menu: NSMenu);
|
||||
begin
|
||||
if Assigned(statusitem)
|
||||
and (statusitem.menu=menu)
|
||||
and (TrayIcon.PopUpMenu = nil) // LCL changes the value w/o letting WS know! :(
|
||||
then
|
||||
menu.cancelTrackingWithoutAnimation;
|
||||
end;
|
||||
|
||||
{ TCocoaWSCustomTrayIcon }
|
||||
|
||||
class function TCocoaWSCustomTrayIcon.Hide(const ATrayIcon: TCustomTrayIcon): Boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user