Post

Replies

Boosts

Views

Activity

Reply to Jump to Definition on Symbols in a Swift Framework's Gigantic Generated "Header"?
FWIW command+clicking on a symbol works sometimes even though there is no "Jump to Definition" context menu item. I think "Jump to Definition" would be useful since so much is scattered about. IMHO it would be better if these generated framework interfaces would instead create separate files grouped logically (in the way you would organize them if you were creating the header files yourself) instead of just dumping everything in gigantic generated interface file with protocols and extensions galore and you gotta hop all over the place to get a sense of an API.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’23
Reply to Customize NSToolbar context menu on Sonoma
It is important. I'm fully aware the way we do it is a hack and it was not that unexpected to see it stop working at some point... Then instead of doing this: NSView * theContentView = myWindow.contentView; NSMenu * theCustomizeMenu = theContentView.superview.menu; You can try can try enumerating subviews from the content view superview until you find it. Ideally you should isolate this hack in a category because the code is really nasty. Something like this: //Public @interface NSWindow (FindCustomizeToolbarMenu) -(nullable NSMenu*)findToolbarContextMenu; @end **//Put all the in the .m** #import "NSWindow+FindCustomizeToolbarMenu.h" #import <objc/runtime.h> @interface NSMenu (NSToolbarMenuMarkerHack) @property (nonatomic) BOOL isCustomizeToolbarMenu; @end @implementation NSMenu (NSToolbarMenuMarkerHack) static char const * const ToolbarMenuHackKey = "ToolbarMenuHackKey"; -(BOOL)isCustomizeToolbarMenu { NSNumber *result = objc_getAssociatedObject(self, ToolbarMenuHackKey); return (result != nil) ? result.boolValue : NO; } -(void)setIsCustomizeToolbarMenu:(BOOL)isCustomizeToolbarMenu { objc_setAssociatedObject(self, ToolbarMenuHackKey, @(isCustomizeToolbarMenu), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } @end @implementation NSWindow (FindCustomizeToolbarMenu) -(NSMenu*)searchForCustomizeToolbarMenuInSubviews:(NSArray<NSView*>*)subviews { if (subviews.count == 0) { return nil; } NSMenu *foundMenu = nil; for (NSView *aSubview in subviews) { NSMenu *theMenu = aSubview.menu; if (theMenu.isCustomizeToolbarMenu || [theMenu.itemArray.lastObject.title isEqualToString:@"Customize Toolbar…"]) // <--Should compare a localized string! If you append on the found menu later this check will fail because "Customize Toolbar…" will no longer be the last object! { foundMenu.isCustomizeToolbarMenu = YES; //Mark it in case you mutate the menu later and "Customize Toolbar…" is not the last menu item. foundMenu = theMenu; break; } } //Found it? if (foundMenu != nil) { return foundMenu; } else { //Didn't find it. Dig through descendant views. for (NSView *aSubviewToDigIn in subviews) { NSMenu *nested = [self searchForCustomizeToolbarMenuInSubviews:aSubviewToDigIn.subviews]; if (nested != nil) { foundMenu = nested; break; } } return foundMenu; } } -(NSMenu*)findToolbarContextMenu { NSView *theContentView = self.contentView; NSView *contentViewSuperview = theContentView.superview; NSMutableArray *theSuperViewSubviews = [contentViewSuperview.subviews mutableCopy]; [theSuperViewSubviews removeObject:theContentView]; //Don't need to search the content view since we know it doesn't have it. NSMenu *foundMenu = [self searchForCustomizeToolbarMenuInSubviews:theSuperViewSubviews]; return foundMenu; } This is very ugly and fragile and untested so inspect the code and use at your own risk. But in theory you should be able to do something like this using the category: NSMenu *toolbarMenu = [self.window findToolbarContextMenu]; [toolbarMenu addItemWithTitle:@"CUSTOM" action:nil keyEquivalent:@""]; You could try filing a Feedback and ask Apple to improve the API but I have my doubts about that. You'd at least have to wait a year for them to add it and there's a good chance they never will.
Topic: UI Frameworks SubTopic: AppKit Tags:
Oct ’23
Reply to Jump to Definition on Symbols in a Swift Framework's Gigantic Generated "Header"?
Oh my, the SwitfUI generated "Interface" is a single 85833 lines and there's no "Jump to Definition" menu item when you right click on any symbols. And because almost everything is Protocols in Swift you can't reason about the API using this generated interface because when you right click on a protocol you can't jump the definition of the protocol. You got 85 thousand lines to scroll through to find it. Does everyone really like working like this? Is it really that hard to write a header file? Just asking.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’23
Reply to Find all Finder tags
This limitation never made any sense especially given the fact that NSURL has NSURLTagNamesKey which may be set and get. Way back in the day I was looking to do this. I naturally thought NSWorkspace API related to "file labels" (which I think tags replaced) would maybe just map to tag names but it didn't work. NSWorkspaceDidChangeFileLabelsNotification never got posted so I gave up.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’23
Reply to AVSpeechSynthesizer is broken on iOS 17 in Xcode 15
@dw_dw My TSI got credited back to my account and they said there is "no workaround" and the issue is being investigated. I was wondering the same thing about 17.1 beta but haven't checked it out myself. Sidenode for whatever reason e-mail notifications aren't working for me on this thread even though I'm watching it. Have to check back manually periodically to see if anyone is posting here.
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’23