368
questions
0
votes
1
answer
57
views
How to get Menustyle for Views in SwiftUI Without using Menu?
I have an status menu that uses NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength). I am porting a MenuBarExtra that has many Views and state attributes. I want to avoid using ...
-1
votes
1
answer
29
views
How do I get the macOS app-specific Help menu search bar to appear?
I have a macOS app written in objective-c. Initially, I didn't want to provide a Help menu, so I removed the 'Help' top-level menu item from the storyboard.
Now I want to add a help facility, and ...
0
votes
1
answer
59
views
How to pass a Rust function as a selector into NSMenuItem.action using objc2?
I have the next code to build an application menu in AppDelegate (an AppDelegate code was taken from the official example):
impl AppDelegate {
fn new(mtm: MainThreadMarker, menu: Option<Menu>...
1
vote
0
answers
76
views
Mac app's Enter Full Screen functionality is not working
I'm encountering an issue while developing my Mac app and I have a question.
Even in a test app with no additional features, after Hide (cmd + h) or Minimize (cmd + m) and then activating the app ...
1
vote
0
answers
57
views
Why is a dummy NSMenuItem needed to make the next NSMenuItem actually appear?
I want to programmatically populate an NSMenuToolbarItem's NSMenu.
let toolbarItem = NSMenuToolbarItem(itemIdentifier: ...)
toolbarItem.image = ...
toolbarItem.label = ...
toolbarItem.menu.delegate = ...
0
votes
0
answers
143
views
NSMenuItem not clickable after updating to Sonoma
I have a CEF application where the menu bar is set programatically. On Ventura, the menu bar behaved as expected, but after updating to Sonoma, clicking on any menu item does not expand it. This ...
2
votes
0
answers
211
views
How to use SwiftUI in NSMenu?
I'm new to Swift and I am developing a menubar app.
I have a SwiftUI view with a bunch of Picker and Text views, and display data. The SwiftUI in menubar NSMenu is not clickable and greyed out.
struct ...
1
vote
0
answers
97
views
Unable to dismiss "NSWindowController" for a Mac app
I have created a menu bar app for Mac. I want to open the app when clicking on menu bar icon. After updating the OS to Ventura (13.4 (22F66)) I am observing an issue where the NSWindowController is ...
0
votes
0
answers
61
views
NSCollectionView inside NSMenu don‘t update properly when menu not shown
I want to put an NSCollectionView inside a menu. It's pretty simple:
private func configurePlaylistLibraryMenu() {
let playlistlibraryvievController = PlaylistLabraryViewController(player: ...
1
vote
1
answer
602
views
Displaying NSMenuItem in SwiftUI on it's own
I have been trying to display a custom NSMenuItem (for a preview page of a menu manager) inside a SwiftUI view. But I can't achieve it. I have figured it needs to wrapped inside a menu first, and ...
2
votes
0
answers
61
views
NSMenu Subclass does not respond to mouse click
I am subclassing an NSPopUpButton with the purpose of having control over the drawing methods of the button itself, but also the NSMenu that will pop up. Therefore I am also subclassing NSMenu and - ...
0
votes
2
answers
171
views
Application main NSMenu not responding without window reactivation
I'm trying a minimalistic Cocoa app as described in this page
using code:
#import <Cocoa/Cocoa.h>;
int main ()
{
[NSAutoreleasePool new];
[NSApplication sharedApplication];
[NSApp ...
0
votes
0
answers
67
views
MacOS Cocoa Detect When Keyboard Macro Program Presses Modifier Keys
I am working on a third-party plugin in a host application (Finale). My plugin can tell Finale to create any number of menu options in its designated menu. My plugin can then fish them out and ...
0
votes
1
answer
236
views
refresh NSMenuItem on click/open of NSStatusItem
I have the following extension where I have a NSMenuItem with it's state being either on or off:
extension AppDelegate {
func createStatusBarItem() {
let sBar = NSStatusBar.system
...
2
votes
0
answers
226
views
NSMenuItem.separator() is a blank space rather than a line
I'm building a Finder extension for OSX, I want to add a separator to the contextMenu of Finder, but I can't see the separator line:
The separator I want to add is like this:
Here is the related ...
0
votes
1
answer
252
views
Swift NSMenu items are grey out
I have a menu with menu items. The problem is that my menu items are all greyed out or not enabled
public override init() {
super.init()
let menu = NSMenuItem(title: "Debug", action: ...
0
votes
1
answer
777
views
How to customize a NSPopUpButton and its NSMenu?
I want to style a NSPopUpButton with my own colors. I've gotten pretty much everything else to work except for the caps at the top and bottom of the menu and I can't get the NSPopUpButton to show an ...
0
votes
1
answer
605
views
Show NSMenu when clicking on a Button in SwiftUI view
I'm trying to show a NSMenu when clicking on a Button in a SwiftUI view, but nothing is displayed with the code I'm using. Here it is:
HStack {
Spacer(minLength: 100)
Button(action: {
...
1
vote
0
answers
24
views
Disable clicking on FinderSync extension submenu
I am writing a FinderSync extension in Swift, and am creating a submenu like such:
let menu = NSMenu(title: "")
let newsub = NSMenu();
newsub.addItem(withTitle: "Folder", action: #...
-1
votes
1
answer
507
views
Adding NSMenuItem to NSApp.MainMenu not inserting new menu item
I'm using the following code to add a new menu item programatically
override func viewDidLoad() {
let mainMenu = NSApp.mainMenu
let myMenu = NSMenuItem(title: "MenuTitle", action: ...
0
votes
0
answers
240
views
Cocoa macOs NSMenu, contextMenu, right click
I searched the all posts and around on the internet but couldn't find anything for mac app that could solve my problem.
The contextMenu is not displayed when I start the app and right click.
// MARK: -...
0
votes
4
answers
220
views
Where can I declare my trigger for NSMenu?
I manually created an NSMenu in my AppDelegate like so:
class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
...
1
vote
0
answers
160
views
Is there a way to get keyboard input inside an NSMenuItem?
I'm trying to make an NSMenu which contains an NSMenuItem, and inside that NSMenuItem I want a TextField that I can interact with. My goal is to make a menubar note taking app, so in theory I could ...
2
votes
1
answer
585
views
How do I detect if an NSMenu is closed?
I started down this rabbit hole because a SwiftUI button, designated to pop up a menu, with a .buttonStyle(BorderlessButtonStyle()) style wasn't behaving correctly when switching from a light to a ...
0
votes
0
answers
181
views
Populate submenu when NSMenu/NSMenuItem are moused over?
On MacOS, I have a submenu with dynamic contents that would be expensive to constantly rebuild. It would be great if when the user moves the mouse over the parent item -- before the submenu is ...
4
votes
2
answers
537
views
How to create an NSMenu containing an NSMenuItem which only appears while holding a keyboard modifier key?
I'd like to create an NSMenu containing an NSMenuItem which is hidden by default, and only appears while the user is holding a keyboard modifier key.
Basically, I'm looking for the same behaviour as ...
0
votes
1
answer
570
views
Open and bring new window to front when pressing NSMenuItem
I have a macOS menu application that is running as an agent (LSUIElement).
I need it to have a companion settings window. There is a "settings" NSMenuItem in the NSMenu, and the requirement ...
1
vote
1
answer
265
views
View in NSMenu not clickable if window is invisible
I experience a really strange behaviour with an NSMenu in an "Application is agent"-Application.
I have the following simple code to setup a titlebar icon with an NSMenu. The menu contains a ...
1
vote
1
answer
689
views
How to add a button to a NSMenu that is used as Status bar menu?
I am using following code to create a statusbar menu for my app on MacOS:
let statusBarItem = NSStatusBar.system.statusItem(withLength: -1)
func applicationDidFinishLaunching(_ aNotification: ...
0
votes
2
answers
90
views
Create Cocoa application without NSMenu
I'd like to create an application that pops up dialogs based on system events. However, this application should not have an NSMenu associated with it.
What I've tried, none of which worked:
Removing ...
3
votes
2
answers
380
views
Toggle NSStatusItem's Menu Open/Closed Using Hot Key - Code Execution Queued/Blocked
I'm editing this question because I think I may have oversimplified the way in which my status item's menu opens. It's ridiculously complicated for such a simple function!
My status item supports both ...
0
votes
1
answer
269
views
Is NSMenu willClose notitfication possible?
Is it possible for an NSMenu object to notify BEFORE it'll close, not after? Its delegate has method didClose(_:) but I want to update its items before it actually closes, since the disappearing ...
1
vote
1
answer
626
views
How to create Cocoa app main menu application programatically [closed]
I am creating simple Cocoa application from scratch, just to learn the process.
However I am not able to create Application Menu. I have this code:
- (void)applicationDidFinishLaunching:(...
11
votes
1
answer
3k
views
SwiftUI: How to implement Edit menu in macOS app
I am building a macOS-app using SwiftUI and the new App lifecycle.
All the default macOS menu items (like cut, copy, paste) are already there after starting a new project but they’re greyed out. How ...
8
votes
4
answers
3k
views
SwiftUI: Change “About View” in macOS app
I am building a macOS-app using SwiftUI and the new App lifecycle.
I would love to change the contents of the “About Window” (that appears when you tap “About DemoApp” in the apps’ menu) but have no ...
4
votes
1
answer
410
views
How to enable auto generation of Window MenuItems (e.g. Tile Window to Left/Right of Screen and Open file with checkmark) in macOS menubar
I am currently creating a macOS menubar for an app without using any interface builder (no XIB/NIB files), just pure code. However I was expecting some items to be auto-generated during the start-up ...
0
votes
2
answers
554
views
NSMenuItem with custom view disappears while scrolling
I implement a NSMenu with NSMenuItem and set custom view to it. When menu is scrollable, mouse hovering on ▼ button to scroll will cause some menuItem disappear (or not draw correctly). Hope someone ...
1
vote
2
answers
277
views
Listen for Actions on a NSStatusItem With a Menu
I have a NSStatusItem with a menu attached. How can I get mouse/touch events from the status item without losing the menu? I was thinking perhaps some kind of workaround where I take in the events and ...
6
votes
0
answers
503
views
NSMenuItem with custom view in macOS 11 Big Sur
macOS 11 Big Sur in its current iteration (beta 1 through beta 6) has a bug/feature that makes it hard to have NSMenuItem with the custom view. Specifically, the custom view of an item won't get a ...
0
votes
1
answer
195
views
Enable menu items and call function when activated in AppleScript
I'm trying to enable the NSMenuItems that I have but it doesn't seem to be working. I'm not sure what I'm doing wrong and I'm fairly new at AppleScript. When the menu items are clicked they need to ...
3
votes
1
answer
547
views
How do I use isAlternative with an NSMenuItem with a customView?
I'm attempting to use the isAlternative property with an NSMenuItem with a custom view. It is not behaving as a standard NSMenuItem without a custom view. How do I get the standard modifier-key ...
0
votes
0
answers
60
views
MacOS 11: NSMenu 3px too small
On MacOS 11.0 Beta (20A4299v), I created a new MacOS app project in XCode (11.4.1 (11E503a)).
I added a NSPopUpButton to the default window, and introduced the following to customize this ...
1
vote
1
answer
555
views
Objective-C, NSPopMenuButton & NSMenu Color
I have an NSPopMenuButton which is connected to an NSMenu in the standard way. I tried sub-classing both in an attempt to change the background color of the menu itself. I'm clearly not doing ...
0
votes
0
answers
93
views
Find out from which control a popup menu is triggered
I have a series of NSButtons on a window, whose menu property is connected to a common NSMenu in the storyboard. In the action method triggered by that menu's item(s), I would like to find out which ...
1
vote
1
answer
735
views
Custom NSMenuItem with right-aligned detail text label
What I want to implement
I am looking for a way to display a title label and a detail text label in a NSMenuItem.
Preferably it would look something like this:
The Title Label is left aligned with ...
0
votes
1
answer
449
views
Why is my NSMenuItem is disabled when it has an action?
I'm implementing a custom NSToolbarItem that has a button and a dropdown, like Mail. The only thing that's not working, though, is that the NSMenuItem is disabled. Whatever I do, I can't get it ...
0
votes
1
answer
225
views
Is `Control Click` meant to be the same as the `right click` for macOS?
I have a NSTableView in which cells are NSTextFields.
I assign a menu to the text fields.
Menus are supposed to open when I right click on a cell.
I have this secondary click equal to click on the ...
0
votes
1
answer
149
views
Why can my app only see selectors for menu items if they are in the AppDelegate?
I am building my first macOs app in Swift. I have managed to add a menu (NSMenu) to the Menu Bar Extra icon, but when the menu loads each menu item is shown as deactivated. I understand this is ...
2
votes
1
answer
941
views
How to create a NSMenu Instance with SwiftUI?
I have look made some search, however could not find any information. Question is pretty straight-forward. I don't know if it is possible, but, in this link they could create a NSMenu item via xib ...
2
votes
0
answers
555
views
NSMenuItem alternate item with no keyboard shortcut
I have a menu item that by default uses app state to trigger its enabled-ness. But in very rare situations (usually during interaction with customer support), we need to allow the user to trigger the ...