Moving menu items to app menu on Mac

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Moving menu items to app menu on Mac

Post by monte » Wed Dec 18, 2013 9:36 pm

I've been asked to investigate options for moving appropriate menu items to the app menu. The item in question is "Check for updates" which is usually in the app menu. While it's easy enough to write an external I think the way the engine trashes all the menus and re-builds them each update will interfere so I think that rules it out. So I've proposed a possible engine solution which may be more work than the client is interested in paying for but here goes:

The idea is to implement a method in the engine to specify which menu items should be moved to the app menu. I'm thinking a multi-dimensional global array property which would default to about and preferences:

Code: Select all

applicationMenuItems
              [item order 1..n]
                           ["menuName"] -> the name of the button the item is in
                           ["tag"] -> a tag for the button
                           ["menuItem"] -> the item - a fallback if the tag isn't found and only
                                                   match the length of the menuItem so
                                                   for  "About Appname" you could use "About"
                           ["removeSeparatorLine"] -> 1...n or -n...-1 or empty
                           ["line"] -> 1...n or -n...-1
The default for this array would be:

Code: Select all

applicationMenuItems
          [1]["menuName"] -> "Edit"
              ["tag"] -> "preferences"
              ["menuItem"] -> "Preferences"
              ["removeSeparatorLine"] -> -2
              ["line"] -> -1
          [2]["menuName"] -> "Help"
              ["tag"] -> "about"
              ["menuItem"] -> "About"
              ["removeSeparatorLine"] -> -2
              ["line"] -> -1
I believe this array covers all the data required by MCScreenDC::updatemenubar. The other issue here is this all needs to be updated for Cocoa so there's probably not much point making significant changes without doing that.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: Moving menu items to app menu on Mac

Post by LCMark » Thu Dec 19, 2013 7:22 pm

As it turns out I was pondering this the other day when I was working on the Cocoa port. Whilst a global array would work fine, it means that script has to run in order to ensure menus are appropriately organised on Mac compared to the other platforms. So how about this for a counter-proposal:

If the menu group contains a button named 'Mac Application' (or something similar), then this is taken to be the Application menu on Mac and ignored on the other platforms. This menu is taken to be what the application wants the app menu to be with tags being used to control the movement of menu items.

In this menu, tags can either be usual tags or of the form <menu>|<tag>.

In the former case things work as you'd expect - you'll get a menuPick message sent to the Mac Application button for their selection.

In the latter case, the tag indicates that the menu item in Mac Application replaces the item with tag <tag> in menu <menu> (<menu> is the name of the button in the menubar group). In this case, menuPick will be sent to button <menu>, rather than "Mac Application".

The current logic of using some tags to indicate the standard items (About, Preferences etc.) would remain.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Moving menu items to app menu on Mac

Post by monte » Thu Dec 19, 2013 8:58 pm

Hmm... that does sound easier. So you would only need to do this for extra app menu items and the current logic for prefs and about would remain as is? I guess any extra separator removal if necessary could be done by the developer. OTOH as this would just be a hidden button it perhaps makes just as much sense to use a property of the menu group. Indeed it looks like I forgot to mention that as an alternative. The flat format is probably easier for someone typing the list in somewhere.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: Moving menu items to app menu on Mac

Post by LCMark » Thu Jan 09, 2014 12:00 pm

@monte: Just to clarify, my suggestion here was that if the user adds a 'Mac Application' button to the menu group then it would supercede 'default' application menu behavior in the sense that it would be taken to be the application menu - i.e. the engine would not synthesize one itself. In such a case, menu items would be removed from other menus as necessary based on the tag of the item. Separator removal could be rolled in here by allowing tags on separators too - for example if you have a menu item tagged 'Foo|Bar' in Mac Application, and a menu:

Code: Select all

menu "Foo"
  Baz
  -|Bar
  Bar|Bar
This would cause both the separator and the 'Bar' item to be removed.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Moving menu items to app menu on Mac

Post by monte » Fri Jan 10, 2014 1:01 am

Sounds good to me
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Locked

Return to “Engine Contributors”