Page 1 of 1

Best practice on menues?

Posted: Fri May 13, 2011 5:06 am
by tarmsaft
Since it is not possible to run multiple instances of programs on the mac (as far as I know) I have to open several windows instead.
I would like to have the same menu on all open windows, and I want a standard "Window" menu with a list of all open windows. Only the active window should have keyboard shortcuts enabled. That is, it should resemble all other mac applications.

How do you propose I do it with as little fuss as possible?
  • Should for instance each window have it's own menu?
  • How do you update the menu in a efficient manner? Rebuilding every menu when the windowtitle changes on a menu, another window gets active (needed to indicate which window is active), or when you add/remove windows
  • The keyboard shortcuts. Deactivate all and create new listeners every time a window becomes active?

Re: Best practice on menues?

Posted: Fri May 13, 2011 6:24 am
by WilliamL
You can only have one set of menus on the Mac and it is associated with one open window but all windows seem to be able to access this menu set. MenuShortcuts don't seem to be active when you're not in the window that created them so just make the menu shortcuts and see how it goes. Just be sure not to close the window that created the menus.. or recreate them in another open window before closing the original window. Otherwise, there isn't any updating of menus necessary, if I understand your question.

Re: Best practice on menues?

Posted: Tue May 17, 2011 9:28 am
by tarmsaft
WilliamL wrote:You can only have one set of menus on the Mac and it is associated with one open window but all windows seem to be able to access this menu set. MenuShortcuts don't seem to be active when you're not in the window that created them so just make the menu shortcuts and see how it goes. Just be sure not to close the window that created the menus.. or recreate them in another open window before closing the original window. Otherwise, there isn't any updating of menus necessary, if I understand your question.
I'll give it a try. I'm not sure about the short cuts though. They don't seem to be "transferred" to the active window. But i'll give it another go.

However it does not count for a window drop down menu that is updated whenever windows open, close or becomes active.

Example
1. Open two windows of TextEdit
2. The second from the right drop down menu is entitled "Window" (That is the Apple sign to the left, following with "File", "Edit", "Format", "Window" and finally "Help")
3. Click "Window", you should now see both of you windows open. One having a checkbox indicating the active one.

How does one do that without constantly updating the windowmenu?

Re: Best practice on menues?

Posted: Tue May 17, 2011 5:14 pm
by WilliamL
I don't know how others do it but I use a "MenuUpdate" procedure any time a window is closed or file is modified etc. I am calling that routine all the time through out my program.