Code to make popup menu show options without clicking on it.

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

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Code to make popup menu show options without clicking on it.

Post by CAsba » Mon Mar 20, 2023 6:56 pm

Hi,
I was trying to figure out how to write code for a popup menu to open - to show the menu options - when I came across a previous thread pertaining to it.
Code was given as

Code: Select all

click at the loc of btn "optionButton"
which I adapted to

Code: Select all

click at the loc of btn "popup menu1"
.

In the thread this was acclaimed to be the solution, but with me, the menu options were displayed only momentarily then disappeared, too quickly for the user to read them and click on a selection. I tried locking the screen but with no success.
Anyone got any ideas ?
v10.0(dp 4) : Windows 10

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Code to make popup menu show options without clicking on it.

Post by Klaus » Mon Mar 20, 2023 7:06 pm

Works here on my Mac!?
Maybe it will behave different on Windows?
popu.png
P.S.
Tested with LC 9.6.9 rc2

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

Re: Code to make popup menu show options without clicking on it.

Post by dunbarx » Mon Mar 20, 2023 8:56 pm

CAsba.

There are indeed many threads on this forum about that topic, including things to do after it opens. Looking at your code, it seems fine.The menu should stay open, because there is no reason for it to close. That said, I am on a Mac, and expect sanity.

Craig

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Re: Code to make popup menu show options without clicking on it.

Post by CAsba » Wed Mar 22, 2023 12:31 pm

I've spent a lot of time playing with this, changing the inspector settings and messing with the code, but cannot get the the menu options to stay visible. Perhaps I should mention that the options are long pieces of text, but they stay visible when I click the btn.
Anyone got any further ideas about this ?

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

Re: Code to make popup menu show options without clicking on it.

Post by dunbarx » Wed Mar 22, 2023 2:06 pm

CAsba.

I mad an option menu with several long lines of code, and remotely clicked at the loc of the button. All worked just fine.

Try this on a NEW stack with a standard button and an option button. Put this in the standard button script:

Code: Select all

on mouseUp
   click at the loc of btn 2 --the option button
end mouseUp
Does that work?

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Re: Code to make popup menu show options without clicking on it.

Post by CAsba » Wed Mar 22, 2023 2:36 pm

Hi Dunbarx,
Thanks for your interest.
O did exactly as you suggested..
Result ?
Just the same the options show for around one second, then disappear.

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

Re: Code to make popup menu show options without clicking on it.

Post by dunbarx » Wed Mar 22, 2023 3:35 pm

Hmmm.

You are on Windows, I see. Well, what do you expect?

Anyone else duplicate, or have even heard of this?

Craig

Cairoo
Posts: 107
Joined: Wed Dec 05, 2012 5:54 pm

Re: Code to make popup menu show options without clicking on it.

Post by Cairoo » Wed Mar 22, 2023 4:05 pm

CAsba,

If it's a popup menu button, the following works on desktop platforms:

Code: Select all

popup btn "popup menu1" at the clickloc
and then the button itself doesn't need to be visible. I used the clickloc but you can specify any loc.

- Gerrie
Last edited by Cairoo on Wed Mar 22, 2023 4:08 pm, edited 2 times in total.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Code to make popup menu show options without clicking on it.

Post by SWEdeAndy » Wed Mar 22, 2023 4:06 pm

dunbarx wrote:
Wed Mar 22, 2023 3:35 pm
Anyone else duplicate, or have even heard of this?
It might be related to the general misbehaviour of popup buttons in Windows — that they do not pause the script to wait for user input (contrary to what the docs say and how it works on Mac).

I just ran into this issue the other day and found a bug report from 2017:
https://quality.livecode.com/show_bug.cgi?id=20695
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Re: Code to make popup menu show options without clicking on it.

Post by CAsba » Wed Mar 22, 2023 6:08 pm

Hi Gerrie,
I tried

Code: Select all

popup btn "popup menu1" at the clickloc

and

Code: Select all

popup btn "popup menu1" at the loc "619,511"
but not even a glimpse of the options.
Thanks anyway.

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

Re: Code to make popup menu show options without clicking on it.

Post by dunbarx » Wed Mar 22, 2023 6:13 pm

Andy makes a great point, though I would modify it slightly to make the process seem more natural:

Code: Select all

  popup btn "yourOptionButton" at the loc of btn "yourOptionButton"
Craig

Cairoo
Posts: 107
Joined: Wed Dec 05, 2012 5:54 pm

Re: Code to make popup menu show options without clicking on it.

Post by Cairoo » Wed Mar 22, 2023 9:59 pm

CAsba wrote:
Wed Mar 22, 2023 6:08 pm
Hi Gerrie,
I tried

Code: Select all

popup btn "popup menu1" at the clickloc

and

Code: Select all

popup btn "popup menu1" at the loc "619,511"
but not even a glimpse of the options.
Thanks anyway.
If your popup menu button's name is not "popop menu1" then substitute "popop menu1" with the actual name of your popup menu button.
But if it still does not work, then good luck. It works on my Windows system.

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

Re: Code to make popup menu show options without clicking on it.

Post by dunbarx » Thu Mar 23, 2023 12:59 am

@Cairoo.

You have a Windows machine and the above gadgetry works OK?

@CAsba It is something in your machine. Have you tried restarting?

Craig

Cairoo
Posts: 107
Joined: Wed Dec 05, 2012 5:54 pm

Re: Code to make popup menu show options without clicking on it.

Post by Cairoo » Thu Mar 23, 2023 6:58 am

@Craig,

Yes I have a Windows machine and the popup command works. We both came up with the same idea just a few minutes apart, but your button is named slightly better than mine.

- Gerrie

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Re: Code to make popup menu show options without clicking on it.

Post by CAsba » Thu Mar 23, 2023 1:59 pm

Hi,
I tried re-starting, even de-cluttered the desktop, but the problem persists. Thanks anyway.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”