Post

Replies

Boosts

Views

Activity

Spotlight results not working when the app is not running
I'm working on Spotlight integration for my mac app, I just indexed the data with CoreSpolight everything working fine when the app is running. I'm using below mentioned NSApplicationDelegate method to open corresponding content when the user taps the spotlight result. func application(_ application: NSApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void) -> Bool This method is not triggering when the app is not running (Ensured using NSLog). And I'm expecting it has to open my application as well But both not working as I expected. What am I missing in this implementation?
1
0
1.3k
May ’22
How to modify browser requests from the mac app
I'm working on a mac app that is based on links like bitly, using that app users can create a short link mapping to the URL. For instance todayMeet = {myZoomMeetingURL}. Now I'm looking to implement a feature that helps the user to access the short link from the browser. If the user enters the short link in the browser and it has to open the respective URL. Let's say the user enters todayMeet in the browser then it'll take the user to the zoom meeting room. To achieve this, I basically need to intercept all the browser requests (with user consent) and have to replace the respective URL if it is related to my application. As far as i searched found a network extension might be the one that I'm looking but I'm not sure it'll definitely solve my problem. Before diving into this further just want to confirm Am I in the correct direction so far or is there any other ways to achieve this?
1
1
478
Jun ’22
How to get focused element's cursor position using accessibility API?
I'm working on a mac app that uses Accessibility APIs to get the cursor position from the focused element (Focused element can be from any app) and shows a window near the cursor position. I checked the window positioning in native apps like XCode, Notes, and Messages and tried on web apps as well everything is working fine. I checked the same on the slack desktop app where I'm facing an issue. Which is I'm getting the XOrigin always as 0 and YOrigin as 982 (That is equal to my screen's size: NSScreen.main?.frame.height). Seems it is breaking on electron apps. What am I missing here? Do we need to account for anything else to handle electron apps? Attaching my code for reference. extension AXUIElement {   func getCursorRect() -> CGRect? {     guard let cursorPosition = cursorPosition else {return nil}     var cfRange: CFRange = .init(location: cursorPosition, length: 1)     let axval: AXValue? = AXValueCreate(.cfRange, &cfRange)     var bounds: CFTypeRef?     guard let axval = axval else {return nil}     AXUIElementCopyParameterizedAttributeValue(self, kAXBoundsForRangeParameterizedAttribute as CFString, axval, &bounds)     var cursorRect: CGRect = .zero     guard let bounds = bounds else {return nil}     AXValueGetValue(bounds as! AXValue, .cgRect, &cursorRect)     return cursorRect   } }
1
0
818
Jun ’22
How to show NSPopover without dismissing the first responder?
I'm working on a mac app that has similar functionalities to the Rocket macOS app. Whenever the user types : outside of my app I'll show an NSPopover with NSTableView near the cursor. The problem I'm facing here is that The moment I show the NSPopover it becomes the first responder and the user couldn't continue typing. So I tried this, Showed the NSPopover without making a first responder, and used NSEvent.addGlobalMonitorForEvents(matching: .keyDown, handler: ) to listen UpArrow, DownArrow and Enter actions to navigate and select results. The downside of this approach: Let's say I'm composing a new mail, and the cursor responding to the up/down arrow events, eventually moved to other lines. Attaching gifs for reference, The functionality that I'm expecting From my app Note: Notice the cursor position to understand what goes wrong.
0
0
702
Jun ’22