Can a livecode app be a menuitem app on Mac?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
micmac
Posts: 49
Joined: Mon May 30, 2011 9:00 am

Can a livecode app be a menuitem app on Mac?

Post by micmac » Tue Oct 10, 2023 12:44 pm

Hi

The topic says it all:

Can a livecode app be a menuitem app on Mac?

Thanks
Mic

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can a livecode app be a menuitem app on Mac?

Post by Klaus » Tue Oct 10, 2023 2:40 pm

Hi Mic,

sorry, I have no idea what that means?


Best

Klaus

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Can a livecode app be a menuitem app on Mac?

Post by matthiasr » 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.

micmac
Posts: 49
Joined: Mon May 30, 2011 9:00 am

Re: Can a livecode app be a menuitem app on Mac?

Post by micmac » Tue Oct 10, 2023 4:03 pm

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

micmac
Posts: 49
Joined: Mon May 30, 2011 9:00 am

Re: Can a livecode app be a menuitem app on Mac?

Post by micmac » Fri Oct 13, 2023 10:17 am

Hi again

I possible, could anybody be kind and give me an example of this?

Thanks
Mic

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can a livecode app be a menuitem app on Mac?

Post by Klaus » Fri Oct 13, 2023 11:12 am

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

micmac
Posts: 49
Joined: Mon May 30, 2011 9:00 am

Re: Can a livecode app be a menuitem app on Mac?

Post by micmac » Fri Oct 13, 2023 12:44 pm

Thank you Klaus

Made your script work! :D

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

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can a livecode app be a menuitem app on Mac?

Post by Klaus » Fri Oct 13, 2023 1:05 pm

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! :-D
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

micmac
Posts: 49
Joined: Mon May 30, 2011 9:00 am

Re: Can a livecode app be a menuitem app on Mac?

Post by micmac » Fri Oct 13, 2023 1:15 pm

Kaffee und Kuchen für dich, Klaus
K&K.jpg
K&K.jpg (23.63 KiB) Viewed 3689 times
Mic

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can a livecode app be a menuitem app on Mac?

Post by Klaus » Fri Oct 13, 2023 1:16 pm

Lecker, vielen Dank! :-)

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can a livecode app be a menuitem app on Mac?

Post by Klaus » Fri Oct 13, 2023 1:20 pm


Post Reply

Return to “Talking LiveCode”