About the application field - is the agent (UIElement) installed on YES?

I am trying to create an application that should only appear on the status bar, and not have a window until you click the NSStatusItem menu options. So, I have one that should open "about"

[[NSApplication sharedApplication] orderFrontStandardAboutPanel:self]; 

But nothing shows whether the Application has a value of YES. If I change it to NO, it will work, but I get the application window and all the menu options that I do not want to see.

Any ideas?

Yours faithfully

+7
agent macos uielement about-box
source share
3 answers

I'll start a new application a few days ago, and I figured it out.

 [NSApp activateIgnoringOtherApps:YES] 

There is a trick!

+7
source share

You have checked this site:

Creating a status bar application

0
source share

I think the most flexible way is that you yourself must take control of the main window instead of the storyboard.

When the application finishes launching, you can show the main window or not according to the application policy, as shown below:

  switch AppDefaults.shared.applicationRunMode { case .menuAndDock: _ = ApplicationMode.toggleDock(show: true) MainWindowController.shared.window?.makeKeyAndOrderFront(nil) case .menuOnly: _ = ApplicationMode.toggleDock(show: false) _ = MainWindowController.shared.window default: MainWindowController.shared.window?.makeKeyAndOrderFront(nil) } 

Actually, the toggleDock method changes the way the application is displayed.

 // Get transform state. let transformState = show ? ProcessApplicationTransformState(kProcessTransformToForegroundApplication) : ProcessApplicationTransformState(kProcessTransformToUIElementApplication) // Show / hide dock icon. var psn = ProcessSerialNumber(highLongOfPSN: 0, lowLongOfPSN: UInt32(kCurrentProcess)) let transformStatus: OSStatus = TransformProcessType(&psn, transformState) return transformStatus == 0 

UIElement in info.plist only allows your Cocoa application to hide the user interface.

0
source share

All Articles