Status menus
Status menus
Were there other changes made to the 6.03 Beta 5? I created an Status bar app using code posted on the forum and even with the proper entry in the Info.plist (the <key>LSUIElement</key>, the compiled code doesn't hide the app in the menu bar. This code works on 6.02 LTS and previous versions.
Re: Status menus
I wish I could help you, but I'm avoiding Betas (and Ventura) for now…
I see Magic Fred is now doing a lot of work on Mac stuff... poor Fred... Thanks!
I heard about many UI problems on apps made "for Ventura but compatible with previous OSs" on Monterey...
Tell Fred your OS
I see Magic Fred is now doing a lot of work on Mac stuff... poor Fred... Thanks!
I heard about many UI problems on apps made "for Ventura but compatible with previous OSs" on Monterey...
Tell Fred your OS
Re: Status menus
Can you post a small code showing the issue ?
Re: Status menus
Code: Select all
EnableExplicit
#NSSquareStatusBarItemLength = -2
Define ItemLength.CGFloat = 32
Define StatusBar.I
Define StatusItem.I
UsePNGImageDecoder()
OpenWindow(0, 270, 100, 300, 100, "SysTray Menu Example")
If LoadImage(0, #PB_Compiler_Home + "Examples/Sources/Data/World.png")
StatusBar = CocoaMessage(0, 0, "NSStatusBar systemStatusBar")
If StatusBar
; ----- Create icon in system status bar (SysTray)
StatusItem = CocoaMessage(0, CocoaMessage(0, StatusBar,
"statusItemWithLength:", #NSSquareStatusBarItemLength), "retain")
If StatusItem
CocoaMessage(0, StatusItem, "setLength:@", @ItemLength)
CocoaMessage(0, StatusItem, "setImage:", ImageID(0))
; ----- Create menu with entries for click on SysTray icon
CreatePopupMenu(0)
MenuItem(0, "Show computer name")
MenuItem(1, "Show user name")
CocoaMessage(0, StatusItem, "setMenu:",
CocoaMessage(0, MenuID(0), "firstObject"))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
Select EventMenu()
Case 0
MessageRequester("Info", "Computer name: " + ComputerName())
Case 1
MessageRequester("Info", "User name: " + UserName())
EndSelect
EndSelect
ForEver
EndIf
EndIf
EndIf
<key>LSUIElement</key>
<true/>
This is incorrect behavior as the app's icon should be hidden not shown.
However, this same code compiled on PB 6.02 and earlier will not show the app icon in the Dock (correct behavior) if the LSUIElement key is added to the Info.plist. I have tested this on an Apple M1 computer using the latest Mac OS
Re: Status menus
Did you try this?
<key>LSUIElement</key>
<integer>1</integer>
Edit/PS: It works here, and even if they say <true/> is the way to go for a boolean, it seems malformed to my old eyes

Re: Status menus
Doesn't work here but appreciate your feedback.
Re: Status menus
I haven't tried 6.03 yet, but I think it could be related to the fix introduced in viewtopic.php?t=77852
The (temporary?) solution would be to explicitly set NSApplicationActivationPolicy after application starts (I provided an example in that topic). Changes in the plist are not needed if you're going to control it in the runtime.
The (temporary?) solution would be to explicitly set NSApplicationActivationPolicy after application starts (I provided an example in that topic). Changes in the plist are not needed if you're going to control it in the runtime.
Oh, that's just a self-closing syntax from XML standard. Technically this is just a short way of writing <true></true>Piero wrote: Sat Aug 19, 2023 10:11 pm It works here, and even if they say <true/> is the way to go for a boolean, it seems malformed to my old eyes![]()
Re: Status menus
Dseven,
I added the following to the start of the program:
And it worked! Thank you!
I added the following to the start of the program:
Code: Select all
application = CocoaMessage(0,0,"NSApplication sharedApplication")
CocoaMessage(0,application,"setActivationPolicy:",#NSApplicationActivationPolicyAccessory)