Page 1 of 1
Can a livecode app be a menuitem app on Mac?
Posted: Tue Oct 10, 2023 12:44 pm
by micmac
Hi
The topic says it all:
Can a livecode app be a menuitem app on Mac?
Thanks
Mic
Re: Can a livecode app be a menuitem app on Mac?
Posted: Tue Oct 10, 2023 2:40 pm
by Klaus
Hi Mic,
sorry, I have no idea what that means?
Best
Klaus
Re: Can a livecode app be a menuitem app on Mac?
Posted: Tue Oct 10, 2023 2:59 pm
by matthiasr
You mean you want your LC app to stay in the menu bar or better said you want your LC app to display a menu in the status bar on Mac?
If that's the question then yes.
Have a look at 'mac status menu' in the dictionary.
Re: Can a livecode app be a menuitem app on Mac?
Posted: Tue Oct 10, 2023 4:03 pm
by micmac
matthiasr wrote: ↑Tue Oct 10, 2023 2:59 pm
You mean you want your LC app to stay in the menu bar or better said you want your LC app to display a menu in the status bar on Mac?
If that's the question then yes.
Have a look at 'mac status menu' in the dictionary.
Thank you matthiasr, but the dictionary is not very helpful. Could you point me to a little example stack that goes into the menubar on Mac?
Thanks
Mic
Re: Can a livecode app be a menuitem app on Mac?
Posted: Fri Oct 13, 2023 10:17 am
by micmac
Hi again
I possible, could anybody be kind and give me an example of this?
Thanks
Mic
Re: Can a livecode app be a menuitem app on Mac?
Posted: Fri Oct 13, 2023 11:12 am
by Klaus
Hi Mic,
you need to know that the menu in the Mac menubar will only visible as long as LC or your standalone is open, even if in background!
If you quit LC or your runtime, the menu will disappear!
OK, here an example with comments, if in doubt, don't hesitate to ask:
Code: Select all
## These two handlers could/shpuld go into the stack script
## And of course you can name the hanlders as you like!
command create_a_menu
## Create a menu with this command.
## the parameter is a name which will not be shown anywhere
## but you will need it to manage the menu later:
macStatusMenuCreate "el_menu"
## Now set some properties to make the menu usable
## ENABLE the menu
macStatusMenuSet "el_menu", "enabled", TRUE
## Define an icon for the menu
macStatusMenuSet "el_menu", "icon", the long id of image "your image here"
## Create the content of the menu
## Hint: I use silly contents, just for the fun of it! :-D
macStatusMenuSet "el_menu", "items", "Blabla" & return & "-" & return & "YaddaYadda"
## Now the menu is visible and active!
end create_a_menu
## What should happen when the user selects a menuitem:
on macStatusMenuPick "el_menu", tSelectedItem
switch tSelectedItem
case "Blabla"
answer "Even more blablablabla..."
break
case "YaddaYadda"
abswer "YaddaYadda, daddy-o! :-)"
break
end switch
## Of course you can execute anything you need instead of my silly ANSWERs :-)
end macStatusMenuPick
############################################################################
## You can remove the menu anytime you want to with_
### macStatusMenuDelete "el_menu"
############################################################################
## Maybe create the menu on openstack
on openstack
create_a_menu
## More openstack stuff here...
end openstack
Hope that gets you started!
Best
Klaus
Re: Can a livecode app be a menuitem app on Mac?
Posted: Fri Oct 13, 2023 12:44 pm
by micmac
Thank you Klaus
Made your script work!
Made this alteration: macStatusMenuSet "el_menu", "enabled", TRUE —> macStatusMenuSet el_menu, "enabled", TRUE. (no quotes on el_menu)
Could not make the icon work. Tried different versions of Long ID with and without quotes, but just got a black square.
NOW, the menuitem I had in mind is actually menuless, but has just one little window for jotting down a sketch and auto coping to clipboard.
so Im a little back to square one...
Mic
Re: Can a livecode app be a menuitem app on Mac?
Posted: Fri Oct 13, 2023 1:05 pm
by Klaus
Hi Mic,
micmac wrote: ↑Fri Oct 13, 2023 12:44 pm
Made this alteration: macStatusMenuSet "el_menu", "enabled", TRUE —> macStatusMenuSet el_menu, "enabled", TRUE. (no quotes on el_menu)
Then this is an error in the Dictionary, will report that.
micmac wrote: ↑Fri Oct 13, 2023 12:44 pm
Could not make the icon work. Tried different versions of Long ID with and without quotes, but just got a black square.
Make sure your image makes sense when displayed in its tinyness!

I think this is 24*24 pixels.
micmac wrote: ↑Fri Oct 13, 2023 12:44 pm
NOW, the menuitem I had in mind is actually menuless, but has just one little window for jotting down a sketch and auto coping to clipboard.
so Im a little back to square one...
Well, since the name of this is macsatusMENU... it can only display a (pulldown) menu.
Best
Klaus
Re: Can a livecode app be a menuitem app on Mac?
Posted: Fri Oct 13, 2023 1:15 pm
by micmac
Kaffee und Kuchen für dich, Klaus

- K&K.jpg (23.63 KiB) Viewed 8721 times
Mic
Re: Can a livecode app be a menuitem app on Mac?
Posted: Fri Oct 13, 2023 1:16 pm
by Klaus
Lecker, vielen Dank!

Re: Can a livecode app be a menuitem app on Mac?
Posted: Fri Oct 13, 2023 1:20 pm
by Klaus