mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 09:16:13 +02:00
cocoa: adding submenu invalidation, so the menuNeedsUpdate is called
git-svn-id: trunk@61262 -
This commit is contained in:
parent
473ea12b96
commit
006c5d25d5
@ -87,6 +87,7 @@ type
|
||||
// of the menu. While LCL allows to modify the menu contents when the submenu
|
||||
// is about to be activated.
|
||||
procedure menuNeedsUpdate(AMenu: NSMenu); message 'menuNeedsUpdate:';
|
||||
procedure menuDidClose(AMenu: NSMenu); message 'menuDidClose:';
|
||||
end;
|
||||
|
||||
TCocoaMenuItem_HideApp = objcclass(NSMenuItem)
|
||||
@ -385,6 +386,28 @@ begin
|
||||
menuItemCallback.ItemSelected;
|
||||
end;
|
||||
|
||||
procedure TCocoaMenuItem.menuDidClose(AMenu: NSMenu);
|
||||
var
|
||||
par : NSMenu;
|
||||
idx : NSInteger;
|
||||
mn : NSMenuItem;
|
||||
begin
|
||||
// the only purpose of this code is to "invalidate" the submenu of the item.
|
||||
// an invalidated menu will call menuNeedsUpdate.
|
||||
// There's no other way in Cocoa to do the "invalidate"
|
||||
par := amenu.supermenu;
|
||||
if Assigned(par) then
|
||||
begin
|
||||
idx := par.indexOfItemWithSubmenu(AMenu);
|
||||
if idx<>NSNotFound then
|
||||
begin
|
||||
mn := par.itemAtIndex(idx);
|
||||
mn.setSubmenu(nil);
|
||||
mn.setSubmenu(AMenu);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaMenuItem_HideApp.lclItemSelected(sender: id);
|
||||
begin
|
||||
// Applicaiton.Minimize, calls WidgetSet.AppMinimize;
|
||||
|
Loading…
Reference in New Issue
Block a user