Page 1 of 1
Status menus
Posted: Sat Aug 19, 2023 7:25 pm
by mrbungle
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
Posted: Sat Aug 19, 2023 7:48 pm
by Piero
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
Re: Status menus
Posted: Sat Aug 19, 2023 8:30 pm
by Fred
Can you post a small code showing the issue ?
Re: Status menus
Posted: Sat Aug 19, 2023 8:49 pm
by mrbungle
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
If you compile this code on PB 6.03 Beta 5 and insert the following key in its Info.plist file, the app's icon will appear on the Dock when run:
<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
Posted: Sat Aug 19, 2023 10:11 pm
by Piero
mrbungle wrote: Sat Aug 19, 2023 8:49 pm
<key>LSUIElement</key>
<true/>
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
Posted: Sat Aug 19, 2023 11:02 pm
by mrbungle
Doesn't work here but appreciate your feedback.
Re: Status menus
Posted: Tue Aug 29, 2023 1:08 pm
by deseven
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.
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
Oh, that's just a self-closing syntax from XML standard. Technically this is just a short way of writing <true></true>
Re: Status menus
Posted: Wed Aug 30, 2023 2:06 am
by mrbungle
Dseven,
I added the following to the start of the program:
Code: Select all
application = CocoaMessage(0,0,"NSApplication sharedApplication")
CocoaMessage(0,application,"setActivationPolicy:",#NSApplicationActivationPolicyAccessory)
And it worked! Thank you!