How to select menuitem by script ?

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7152
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to select menuitem by script ?

Post by dunbarx » Tue Oct 20, 2020 2:39 pm

Here is a stack that has been rolled. Jean-Marc, is it what you intended?
PullDownGadget.livecode.zip
(1.08 KiB) Downloaded 10 times
Craig

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2539
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How to select menuitem by script ?

Post by jmburnod » Tue Oct 20, 2020 5:41 pm

Craig,
No, user must see menuitems list
No need answer dialog, just the same as my stack but simpler with a menu btn.
It is for help users to use tools of one app.
Jean-Marc

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3168
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: How to select menuitem by script ?

Post by mwieder » Tue Oct 20, 2020 5:58 pm

Here's my attempt at dealing with pulldown, option, and combobox menu buttons.
The main code is in the stack script, and the mouseUp handlers in the buttons at the bottom are pretty minimal.
Attachments
buttonPusher.livecode.zip
(1.31 KiB) Downloaded 11 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7152
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to select menuitem by script ?

Post by dunbarx » Tue Oct 20, 2020 6:13 pm

I guess I am just not understanding. All these examples indeed display the dropDown list. None of them, including mine, under script control hilite one of those visible items.

I do not believe it is possible, due to the "blocking" nature of an open menuItem list. One needs a kludge.

Richard had insight into the reasons we see it this way.

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3168
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: How to select menuitem by script ?

Post by mwieder » Tue Oct 20, 2020 6:46 pm

Maybe it's an OS thing then because I'm seeing the option and combo boxes highlight the selection before closing.

[Update] Yep - just tried this on OSX and it's completely different. So much for cross-platform controls.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8143
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to select menuitem by script ?

Post by FourthWorld » Tue Oct 20, 2020 8:04 pm

mwieder wrote:
Tue Oct 20, 2020 6:46 pm
Maybe it's an OS thing then because I'm seeing the option and combo boxes highlight the selection before closing.

[Update] Yep - just tried this on OSX and it's completely different. So much for cross-platform controls.
When should a tools provider like LC embrace OS-native implementations, and when should they invest in reinventing OS-supplied routines in non-standard ways for conformity with other OSes?

I don't have a clear universal rubric to answer that question. But that's the question.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3168
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: How to select menuitem by script ?

Post by mwieder » Tue Oct 20, 2020 8:40 pm

I don't have a generic answer either, but that's not critical to this problem...

OSX option menus show up centered vertically on the current selection (menuHistory).
On linux the options show up as a list below the button.
Windows: dunno.
On linux the controls are not blocked and can still be manipulated.
On OSX clicking on a control blocks anything else from happening until it's clicked to close.

It's not specific to LiveCode, but the way the different operating systems treat the controls.
So I think LiveCode is actually doing the right thing here by not trying to override the OS, even though it makes life harder for us as aspiring cross-platform developers.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7152
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to select menuitem by script ?

Post by dunbarx » Wed Oct 21, 2020 3:52 am

I learned something, which is always nice.

If I needed to make a pulldown act that way I would simply kludge one together. There is no reason to fret over different OS's if a 15 minute gadget does all that is required, and likely more. LC trumps such limitations.

But it is very useful to know that different OS's act differently. In that sense, it is critical, when considering the "Develop here, publish everywhere" paradigm that one also "test everywhere".

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8143
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to select menuitem by script ?

Post by FourthWorld » Wed Oct 21, 2020 7:02 am

Definitely test everywhere. Always. With anything running cross platform, even web pages.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”