Revision: 29752
http://sourceforge.net/p/bibdesk/svn/29752
Author: hofman
Date: 2025-10-22 15:39:58 +0000 (Wed, 22 Oct 2025)
Log Message:
-----------
update menu for bookmarks ourselves for key quivalents, as menuNeedsUpdate is
not called after the first time.
Modified Paths:
--------------
trunk/bibdesk/BDSKBookmarkController.m
trunk/bibdesk/BDSKSearchBookmarkController.m
Modified: trunk/bibdesk/BDSKBookmarkController.m
===================================================================
--- trunk/bibdesk/BDSKBookmarkController.m 2025-10-22 15:03:41 UTC (rev
29751)
+++ trunk/bibdesk/BDSKBookmarkController.m 2025-10-22 15:39:58 UTC (rev
29752)
@@ -321,7 +321,7 @@
}
}
-- (void)updateMenu:(NSMenu *)menu forDisplay:(BOOL)display {
+- (void)updateMenu:(NSMenu *)menu forDisplay:(BOOL)display
{NSLog(@"%i",display);
NSMenu *supermenu = [menu supermenu];
NSInteger idx = [supermenu indexOfItemWithSubmenu:menu];
BDSKBookmark *bookmark = nil;
@@ -357,45 +357,15 @@
}
- (void)menuNeedsUpdate:(NSMenu *)menu {
- BOOL updateImage = ([menu propertiesToUpdate] & NSMenuPropertyItemImage)
!= 0;
- if (updateImage == NO && [[NSUserDefaults standardUserDefaults]
objectForKey:@"NSUserKeyEquivalents"] == nil)
- return;
-
- NSMenu *supermenu = [menu supermenu];
- NSInteger idx = [supermenu indexOfItemWithSubmenu:menu];
- BDSKBookmark *bookmark = nil;
-
- if (supermenu == [NSApp mainMenu])
- bookmark = [self bookmarkRoot];
- else if (idx >= 0)
- bookmark = [[supermenu itemAtIndex:idx] representedObject];
-
- if ([bookmark isKindOfClass:[BDSKBookmark class]] == NO)
- return;
-
- if ([bookmark menuNeedsUpdate]) {
- NSArray *bookmarks = [bookmark children];
- if (supermenu == [NSApp mainMenu]) {
- NSInteger i = [menu numberOfItems];
- while (i-- > 0 && ([[menu itemAtIndex:i] isSeparatorItem] ||
[[menu itemAtIndex:i] representedObject]))
- [menu removeItemAtIndex:i];
- if ([bookmarks count] > 0)
- [menu addItem:[NSMenuItem separatorItem]];
- } else {
- [menu removeAllItems];
- }
- for (BDSKBookmark *bm in bookmarks)
- [self addItemForBookmark:bm toMenu:menu forDisplay:updateImage];
- [bookmark setMenuNeedsUpdate:NO];
- } else if (updateImage) {
- for (NSMenuItem *item in [menu itemArray]) {
- BDSKBookmark *bm = [item representedObject];
- if ([bm isKindOfClass:[BDSKBookmark class]])
- [item setImageAndSize:[bm icon]];
- }
- }
+ [self updateMenu:menu forDisplay:(menu.propertiesToUpdate &
NSMenuPropertyItemImage) != 0];
}
+- (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event
target:(id *)target action:(SEL *)action {
+ if ([[NSUserDefaults standardUserDefaults]
objectForKey:@"NSUserKeyEquivalents"])
+ [self updateMenu:menu forDisplay:NO];
+ return NO;
+}
+
#pragma mark Notification handlers
- (void)handleApplicationWillTerminateNotification:(NSNotification
*)notification {
Modified: trunk/bibdesk/BDSKSearchBookmarkController.m
===================================================================
--- trunk/bibdesk/BDSKSearchBookmarkController.m 2025-10-22 15:03:41 UTC
(rev 29751)
+++ trunk/bibdesk/BDSKSearchBookmarkController.m 2025-10-22 15:39:58 UTC
(rev 29752)
@@ -310,10 +310,7 @@
}
}
-- (void)menuNeedsUpdate:(NSMenu *)menu {
- if (([menu propertiesToUpdate] & NSMenuPropertyItemImage) == 0 &&
[[NSUserDefaults standardUserDefaults] objectForKey:@"NSUserKeyEquivalents"] ==
nil)
- return;
-
+- (void)updateMenu:(NSMenu *)menu {
NSMenu *supermenu = [menu supermenu];
NSInteger idx = [supermenu indexOfItemWithSubmenu:menu];
BDSKSearchBookmark *bookmark = nil;
@@ -341,6 +338,16 @@
[bookmark setMenuNeedsUpdate:NO];
}
+- (void)menuNeedsUpdate:(NSMenu *)menu {
+ [self updateMenu:menu];
+}
+
+- (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event
target:(id *)target action:(SEL *)action {
+ if ([[NSUserDefaults standardUserDefaults]
objectForKey:@"NSUserKeyEquivalents"])
+ [self updateMenu:menu];
+ return NO;
+}
+
#pragma mark Undo support
- (void)handleWillUndoChange:(NSNotification *)notification {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit