Menu PopUp

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Phil_p
Posts: 7
Joined: Wed Sep 07, 2011 10:28 pm

Menu PopUp

Post by Phil_p » Fri Sep 16, 2011 8:20 pm

Hi,

I have a pop up menu which uses a stack as the pop up menu. Within the stack there is a Scrolling List Field, some buttons and some Text Fields. The code for these controls is held within this Stacks script. When I click on the button it shows the stack in the drop down menu but when i click in the stack I can not get the code to run on the stack. The stack closes straight away and the code will only run within the dropdown script.

How can I send the menuPick message to the stack and 'cancel' the drop down cancel message

thanks

Phil

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Menu PopUp

Post by Mark » Sat Sep 17, 2011 12:59 am

Hi Phil,

Your stack should not contain any scripts that run after the stack closes. Scripts in closed stacks can't run.

You have to catch the menuPick message in the script of the button that opens the popup menu stack or higher up the message hierarchy.

If you use the scrolling field to make a choice, you could save this choice in a global variable. This variable will still be available after the stack closes. You can also use a custom property of an object that is stll available after the menu stack closes.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Phil_p
Posts: 7
Joined: Wed Sep 07, 2011 10:28 pm

Re: Menu PopUp

Post by Phil_p » Sat Sep 17, 2011 9:00 am

Hi Mark,

Thanks for your reply.

Currently I can not select items in the list box as when i click on an item in the list it closes the stack. I can use the menupick to catch the users action on buttons etc but it will only access the highlighted item in the listbox which is always the first item irrelevant of where i click.

thanks

Phil

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Menu PopUp

Post by Mark » Sat Sep 17, 2011 9:05 am

Hi Phil,

As you have probably noticed, choices in menus are never made by clicking but by moving. Use the mouseMove handler to change the selectedLine of the list field. Make the list field scroll automatically if the mouse cursor is at the bottom or top of the field. Don't use a scroll bar.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Phil_p
Posts: 7
Joined: Wed Sep 07, 2011 10:28 pm

Re: Menu PopUp

Post by Phil_p » Sat Sep 17, 2011 9:36 am

Hi Mark

Will the mousemove event still work on a iPad app?

Phil

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Menu PopUp

Post by Mark » Sat Sep 17, 2011 9:38 am

Hi Phil,

Yes, I believe it still works on an iPad, but an iPad interface is supposed to be different from a desktop interface so I wouldn't bother using LiveCode's menus.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Phil_p
Posts: 7
Joined: Wed Sep 07, 2011 10:28 pm

Re: Menu PopUp

Post by Phil_p » Sat Sep 17, 2011 9:44 am

Yeh, Im taking your advice on this and have decided to keep the app iPad native

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

Re: Menu PopUp

Post by Klaus » Sat Sep 17, 2011 11:32 am

Hi Phil,

and since iOS only supports the display of ONE stack at a time,
popping up a STACK will not work anyway!


Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Menu PopUp

Post by Mark » Sat Sep 17, 2011 11:39 am

Hey Klaus! That's a nice catch. Didn't think of that. Menus work, though. I wonder how that's done, internally.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply