Option Menu to show menu item by code - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Option Menu to show menu item by code - Solved

Post by DR White » Sun Jul 31, 2016 10:35 pm

I have banging my head now for over 3 hours trying to figured out,
if it is possible to get an Option Menu to show menu items with some program instructions.

If anybody knows how, I would greatly appreciated it.

Thanks,

David
Last edited by DR White on Mon Aug 01, 2016 7:40 pm, edited 2 times in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Option Menu to show menu item by code Not mouse click

Post by richmond62 » Mon Aug 01, 2016 7:43 am

I wonder if you could explain what you mean a bit more clearly.

Do you mean a menu that, when you click on it, shows the underlying code/scripts
behind menu items?

If this is what you mean then it really isn't necessary as one can "fool around"
in the IDE and look at the underlying code within it as much as one wants already.
IDE.jpg
If, alternatively (and your title is a bit difficult to interpret) you want to make a menu drop down
"magically" powered by script that's a different thing altogether, and I wonder what the point of
it would be.

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Option Menu to show menu item by code Not mouse click

Post by DR White » Mon Aug 01, 2016 5:08 pm

richmond62,

I want to make a menu drop down
"magically" powered by script.

I am working on a special IOS app that I need the Option Button menu (IOS picker) to open, when the card is open.

Thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Option Menu to show menu item by code Not mouse click

Post by dunbarx » Mon Aug 01, 2016 6:09 pm

LC is good at magic.

There were threads on this a while ago, but I cannot find them. But start with this. Make an option menu. Make another button. In that other button's script:

Code: Select all

on mouseUp
   click at the loc of btn 1
end mouseUp
Those other threads explored similar kluge methods of selecting menuItems of interest once the menuItems were displayed. This can all be re-created. Can you get going on this?

Craig Newman

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Option Menu to show menu item by code Not mouse click

Post by DR White » Mon Aug 01, 2016 7:39 pm

Craig,

WOW! That works BEAUTIFULLY!

The LiveCode Forum with people like you and many others make using LiveCode worth every dollar!

Thanks,

David

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Option Menu to show menu item by code - Solved

Post by dunbarx » Mon Aug 01, 2016 7:55 pm

Well, glad you like it.

But as for "magic", do you see how the LC environment, in one line, can support such klugey marvels?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Option Menu to show menu item by code - Solved

Post by richmond62 » Mon Aug 01, 2016 8:35 pm

Well, up to a point.

This doesn't work:

on mouseUp
click at the loc of btn "Tools" of stack "revMenubar"
end mouseUp

nor does it work between any 2 open stacks.

This is a pity as the ability to do this would be very useful indeed.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Option Menu to show menu item by code - Solved

Post by dunbarx » Tue Aug 02, 2016 3:20 am

Richmond.

I think one has to be on a card in order to "click"on it. I see no reason why this should be so, as you say. So you must navigate before clicking.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Option Menu to show menu item by code - Solved

Post by richmond62 » Tue Aug 02, 2016 4:55 pm

I suppose one could "navigate" by code as well . . .

This works:

on mouseUp
set the defaultStack to "revMenubar"
click at the loc of btn "Tools"
end mouseUp

Last edited by richmond62 on Tue Aug 02, 2016 7:12 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Option Menu to show menu item by code - Solved

Post by FourthWorld » Tue Aug 02, 2016 5:40 pm

richmond62 wrote:I suppose one could "navigate" by code as well . . .

This works:
Zippedy_Doo_Dah.png
Good fun. If you can figure out a way to type arrow key and Enter key messages you could simulate all sorts of user actions in menus.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Option Menu to show menu item by code - Solved

Post by dunbarx » Tue Aug 02, 2016 6:08 pm

The way around all this is to create a "clicking" message:

Code: Select all

send "clicking" to objectpathName
and then in a card script

Code: Select all

on clicking
   click at the loc of the target
end clicking
Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Option Menu to show menu item by code - Solved

Post by richmond62 » Tue Aug 02, 2016 6:11 pm

Good fun.
Yup.

I wonder how one could do something like this:

(pseudocode)

send (controlKey & 3) to btn "View"

c.f: http://runtime-revolution.278305.n4.nab ... 53818.html

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Option Menu to show menu item by code - Solved

Post by richmond62 » Tue Aug 02, 2016 6:45 pm

This works:

on mouseUp
set the defaultStack to "revMenubar"
click at the loc of btn "View"
select menuItem 3 of btn "View"
end mouseUp


Mind you; that's pretty silly when a "go next" would have done the trick anyway.

The only "slight snag" is that you don't see the menuItem high-lighted.

Also: not a bad idea to have a second "click at loc of" after the select so the
menu doesn't keep hanging down.
Last edited by richmond62 on Tue Aug 02, 2016 7:11 pm, edited 2 times in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Option Menu to show menu item by code - Solved

Post by FourthWorld » Tue Aug 02, 2016 7:02 pm

That triggers the script for the menuitem, but doesn't dismiss the menu, and doesn't even require the menu be dropped down. Might be nice if there was a way to truly simulate selection of a menu, with item flash and all.

PS: Why post screen shots of your scripts instead of just posting the code? The screenshots take up more space, and don't allow anyone to copy the script, requiring them to re-type it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Option Menu to show menu item by code - Solved

Post by richmond62 » Tue Aug 02, 2016 7:13 pm

Why post screen shots of your scripts
Point taken.
Might be nice if there was a way to truly simulate selection of a menu, with item flash and all.

click at the loc of menuItem 3 of btn "View"


didn't do any good at all.

Post Reply