Adding Menus and Major Setbacks

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Adding Menus and Major Setbacks

Post by lohill » Wed Jan 20, 2010 8:08 pm

I have a stack, actually a substack to my 'splash' stack, for which I wanted to add menus. I deleted all but one card and then added a series of drop down menu buttons that I made into a group with background behavior so that they would appear on future cards. I gave them some functionality and did some testing with them that seemed to work. The menus/buttons just sat there near the top of the cards and did their thing.

At the same time I did some testing of making a stand alone application and noticed that the only menu it had was called 'Portfolio Manager' and it had a Quit and other standard functionality. There was nothing in the About because I didn't know how to get it there. None of my menus showed in the Menubar either even though they worked from their positions on the card.

Then I started looking at the menu tutorials in the Resource center. They were not too helpful but I did come across the 'set the menubar' and put the following into the stack script:

Code: Select all

on OpenStack
      set the menuBar of this stack to "Menus"
end OpenStack
This is where things start getting a little 'fuzzy'. As I recall it would not allow me to use 'set the menuBar of this stack to group "Menus". At any rate when I got it to run somehow I ended up with a menubar that started with Revolution and then had my other menu items. To make a long story short by the time I got the Revolution menu looking normal (I was in the IDE), my stack had suffered severe damage. Although I can see all the objects of my application while looking at the Application Browser, a good many of them have disappeared from the card. I can no longer see the navigation buttons that were at the bottom of the card or the buttons that were to be my menus near the top. They don't show up by making the card larger either. I cant seem to figure out how to use the Size and Position option of the Inspector to make them show and I fear that my Geometry settings are all damaged.

Can this be salvaged? If I have to go back to an older version are there good ways to salvage my code. I'm feeling quite discouraged.

Thanks in advance for any advice you can give.
Larry

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Adding Menus and Major Setbacks

Post by Klaus » Thu Jan 21, 2010 9:36 am

Hi Larry,

short question: Mac or Win?
Menus on the mac ARE a bit tricky 8)


Best

Klaus

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Adding Menus and Major Setbacks

Post by lohill » Thu Jan 21, 2010 7:54 pm

Klaus,

This is on a Mac and anything you can add will be a help. Thanks.

Larry

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Adding Menus and Major Setbacks

Post by lohill » Thu Jan 21, 2010 8:54 pm

Klaus,

Mac menus being 'tricky' may be an understatement. I made a simple set of stacks with a main splash stack and a sub stack onto which I put three menu buttons called "Menu 1", "Menu 2" and "Menu 3". Each of those has a "Choice 1", "Choice 2" and a "Choice 3". This pretty much is similar to my project.

When the Splash is opened it waits 10 seconds, beeps and then opens the sub stack which has the following in the stack script:

Code: Select all

on openStack
   set the menuBar of this stack to "Menus"
end openStack
The following is a typical menuPick script for each of the menus:

Code: Select all

on menuPick pItemName
   switch pItemName
      case "Choice 1"
         answer "Menu 2 - Choice 1"
         break
      case "Choice 2"
         answer "Menu 2 - Choice 2"
         break
      case "Choice 3"
         answer "Menu 2 - Choice 3"
         break
   end switch
end menuPick
I saved the stacks, quit REV and the started it again. The splash came up and the the sub stack window just like planned. The menu buttons were 'up in the air' and no longer visible on the card. I now see that if I switch back and forth in the IDE between the 'run scripts pointer tool' and the 'edit objects pointer tool', the menu at the top changes between my menus and the REV menus. The first menu (after Apple) is always Revolution however. The 'tricky' thing I am seeing with my menus is what shows when they are selected.

When I click each of the three choices in Menu 2, I get the display I expect. Menu 1 however gives me one choice only which is called Choice 1 and responds properly. Similarly with Menu 3 - 1 choice for Choice 1. Even more interesting is the Revolution menu which has a choice in the 'About' position that says 'Menu 3 - Choice 3".

This must have something to do with the way the original buttons were placed on the card but I thought I was doing it in a way to keep the layering in order. I drug the first button from the tools then copied and pasted for each of the other two. I haven't had time to explore that yet.

Larry

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Adding Menus and Major Setbacks

Post by Klaus » Fri Jan 22, 2010 2:12 pm

Hi Larry,

to be honest, I can really not help you with your current problem, but can give you some useful hints (hopefully :) )

Mac OS X also does its thing to make confusion even greater!
OS X does this with your menus:
1. It moves the last entry of the last (the button of the right side of your menu group) to the "Application" menu on the left side of the Finder menu.
That's why you find this entry astoundingly in the Rev "Application" menu :)
According to the APPLE HIG this right menu should always be "Help", even if you don't supply any help at all.

2. The last entry in the "Edit" menu (the second button from left) should be "Preferences" according to Apple HIG and is also move into the "App" menu.

And Rev does this with you menu group (from the docs):
"On Mac OS systems, when a stack's menubar property is set, the stack is scrolled and resized on Mac OS systems so that the group is not visible in the stack window..."

All this makes menus a bit tricky as I nicely understated :D

Anyway, here is how I use and manage menus on OS X (and Win):
I create the menu group in a substack but do NOT open this substack on OS X!
Will open this as a palette on Windows however to provide a menubar!
This way I don't have to deal with the "shrinking" stack and the "disappearing" menu group in that substack!
And Rev will find the menugroup in a closed substack anyway!

And yes, when swtching from the Pointer (edit) to Browse tool, the menubar will also change in you stack from the Rev menubar to your menubar, which is also a bit confusing at first, but "normal" behaviour, try to get used to it 8)

OK, I hope I could mske things a bit clearer...


Best

Klaus

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Adding Menus and Major Setbacks

Post by lohill » Fri Jan 22, 2010 6:14 pm

Thanks Klaus,

You have given me some good ideas about how to proceed. Do you do your development on a PC and then port to the Mac? Is that what most people do? Did menus work better with older Mac operating systems? I would think that these menu problems would be a concern for the REV people. Their flaky quirks are enough to drive many people away.

Larry

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Adding Menus and Major Setbacks

Post by Klaus » Fri Jan 22, 2010 6:38 pm

Hi Larry,

great I could help!

I do my dev stuff on macs, at work and at home.

Did menus work better on older Mac OSses?
I really don't remember, been using OS X starting with 10.1 and MetaCard 2.0 and never looked back :)


Best

Klaus

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Adding Menus and Major Setbacks

Post by lohill » Sat Jan 23, 2010 5:18 am

Klaus,

With your help and a little further study of the User Guide, I have decided that it is best for me not to try putting menu buttons in the menuBar. The obstacle that I am not willing to fight is the offset that seems to automatically occur when a menuBar is added on the Mac.

For posterity I would like to summarize what I think I have learned about putting 'real' menus on a Mac application if that is what you want to do. This is how I interpret it so If I'm off base please chime in.

It appears that if you want Mac Menus you need to heed the following:
1. You must have three or more menus which can be named whatever you want but it is probably best that they be names which are 'Apple' like. I'm not sure what the upper limit is but there must be one.
2. You can have as many items as you want in a menu. Again there must be some practical limit.
3. There are some aspects of your menus that the Mac OS takes out of your control and that you must adhere to if you want to be successful.
A. The last item in the first menu button can have any name you want but it must be proceeded with the previous line being a dash or divider. No script is required in the menuPick event and the item will actually appear in the Application menu as "Quit".
B. The last item in the second menu button again can have any name but should have an appropriate script in the menuPick event. It must also be preceded by a dash line. It will show up when the application is run in the Application menu as 'Preferences'.
C. The last item of your last menu must be preceded by a dash and should be "Help". What happens is determined by the menuPick event for that last button but the Help menu shows up in the Application menu along with Preferences and Quit.
4. The other menu Items will appear in their assigned menus and run as directed in their menuPick handlers according to their Switch - Case.

I think I could overcome these strange behaviors since my project is only for the Mac but I just can't see how to handle and correct the 20 some pixel offset that shows up unexpectedly.

Larry

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Adding Menus and Major Setbacks

Post by Klaus » Sat Jan 23, 2010 12:05 pm

Hi Larry,

yes, that is all true!

But there is a stack property which is unfortunately NOT available in the Rev IDE but via script!
Check "editmenus" in the docs (Rev Dictionary)! This might help you.


Best

Klaus

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Adding Menus and Major Setbacks

Post by lohill » Sat Jan 23, 2010 7:02 pm

Hi Klaus,

I think you have given me the key to being able to use real Mac menus. I think if I put the menus on the card first and the edit menus true or false from the message box as needed, I can work with everything and still preserve my geometry.

Thanks for your patience.

Regards,
Larry

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Adding Menus and Major Setbacks

Post by Klaus » Sun Jan 24, 2010 1:27 pm

Hi Larry,

glad I could help!


Best

Klaus

Post Reply