I am writing a menubar application with a popup view but no menu and no storyboard. Among other things, I want to activate a button with keyboard shortcut.
Everything I have found so far is either for Swift 2.0 or for menu based applications. I would like my application to run on Catalina, though by the time it is finished I know that Big Sur will be out.
Is there a way for a SwiftUI button to respond to a keyboard shortcut, or some other way for a view to do that?
I am on MacOS 10.15.6, and XCode 11.7.
Related
Is it possible to add a "New Tab" button to the tabBar, like Safari and Finder has? My app is a Mac Catalyst app and has support for multiple windows, but to open new windows the user has to select it from the menu bar or use keyboard shortcuts.
The idea is to have this built-in Tab Bar work much like https://github.com/stuffmc/TabbedViews does.
.
The built-in one has:
No + button (and no New Tab menu either)
Only the option to display the full display of a window. This one can display the Tab Bar anywhere, and especially also on iOS.
This one though has no support yet for Move Tab to New Window and of course one need not to forget to remove Merge All Windows, otherwise both will conflict.
How can I present a context menu or even better a iOS Popover controller when right clicking in a MacCatalyst app? Right now I have it set up for long presses, not that doesn't feel right on a desktop app.
https://developer.apple.com/design/human-interface-guidelines/ios/controls/context-menus/
We use this to develop right click menus with MacCatalyst
I have a simple Menubar app in which it has 2 options - namely Preferences & Quit
After clicking on Preferences it opens a new window but doesn't show the menu bar
I tried connecting from Main Menu to the Window Controller but it doesn't work.
I drag it from the Application Name to the Window Controller or View Controller using Ctrl+Drag but still it doesn't work.
Another issue is my Preferences Window is resizing even though I unchecked the resize button in the Attributes Inspector.
Even Maximise & Minimise checkboxes are disabled but they are still showing.
Any solutions?
See NSApplication.activationPolicy.
If you want the app's main menu bar to appear, you'll need to change the activationPolicy to NSApplicationActivationPolicyRegular. Once you do that, the app's main menu will appear when your app is the active one. (It will also appear in the dock.)
If you want this to happen only when your preferences window is open, then you'll need to change the activationPolicy when the window opens, then set it back again when it closes.
You don't need to connect any outlets for this; the Main Menu should already be a resource for your app and should be loaded automatically when your app launches.
I think I had given Storyboard Id to my View Controller rather than my Window Controller so it wasn't working.
I also checked some apps like Dropbox which didn't have Main Menu Bar because it was a background or accessory app so I ditched it.
Some apps like Focus have it though. But I went with the popular choice.
As for no resizing, no minimising & no maximising goes, I pasted below code & it worked
var myWindow: NSWindow? = nil
myWindow?.styleMask.remove(NSWindow.StyleMask.resizable)
myWindow?.standardWindowButton(.miniaturizeButton)?.isEnabled=false
myWindow?.standardWindowButton(.zoomButton)?.isEnabled=false
I am developing a menu bar application for os x. I am using NSPopover to create a popup window.
However when some other application is full screen that popup is not visible. What settings should be set, so that popup window is always on top.
I struggled with this as well. When I had this problem, I created a invisible window that would flow above all other windows, including full screen ones. The window would then activate the popover.
However, I found a much cleaner solution here.
I an writing a keyboard extension for iOS8. There is bug in 2 apps and I want to hide my iOS 8 keyboard extension keyboard popup list of the 2 app when user click the global key. I saw some third keyboard can do this.
App can disallow using extension keyboard by shouldAllowExtensionPointIdentifier, but keyboard can't disallow using an app.I think it's that you saw.