Automatically populating menu from list when user clicks

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

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 175
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Automatically populating menu from list when user clicks

Post by kaveh1000 » Sat Feb 09, 2019 3:37 pm

I have been using Menubuilder to create menus, after reading Jeane DeVoto's great tutorial on this page:

http://www.hyperactivesw.com/revscriptc ... ences.html

I am updating the contents of one of the menu items (which are buttons in reality), in real time from a list (actually a remote database). For this I use mouseDown which instantly fills the menu with the remote list, then menuPick to act on each item.

This works when the menubar is on the top of the card as mousedown is recognized. But not when I set the menus to appear in the menubar. What handler can I use instead of mousedown in order to have the same effect?

Bet jacque can help me with this one. ;-)

Kaveh
Kaveh

bogs
Posts: 2817
Joined: Sat Feb 25, 2017 10:45 pm

Re: Automatically populating menu from list when user clicks

Post by bogs » Sat Feb 09, 2019 4:03 pm

I'm confused, the lesson you cite has a section specifically with what your asking about :wink:
Selection_001.png
Say what?
Image

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 175
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Automatically populating menu from list when user clicks

Post by kaveh1000 » Sat Feb 09, 2019 4:57 pm

Hi Bogs

Please see attached stack. The menu item on the top left will dynamically fill with the field text, using mousedown.

Now open Tools > Menubuilder, select that menu item, and click:

Set as Stack Menu bar

Now you can see the menu nicely in the menu bar, but of course mousedown does not work any more, so the menu is not updating.
Attachments
Menu on the fly.livecode.zip
(1.07 KiB) Downloaded 6 times
Kaveh

bogs
Posts: 2817
Joined: Sat Feb 25, 2017 10:45 pm

Re: Automatically populating menu from list when user clicks

Post by bogs » Sat Feb 09, 2019 5:44 pm

I dunno, sure looks like it does here -
Selection_004.png
Hmm...
I put everything just like you said, then -
I deleted all the entries in the menubuilder items
Clicked on the 'on the fly' button again
Everything shows populated from the list

Tells me it is working as you might expect, unless I'm just missing something obvious (I don't work in this version of the IDE a lot, so pretty likely I am just missing something :D )
Image

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 175
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Automatically populating menu from list when user clicks

Post by kaveh1000 » Sat Feb 09, 2019 5:56 pm

Thanks for looking again.

I should have said I am using a Mac. I know menus work differently on different systems. Attached is a screen recording to show how the menus work on Mac. Please see how in the menubar, mouseup does not work. I know it is outside LiveCode's control at that point but love to find a solution.

Please see file here:

https://drive.google.com/open?id=1iENAA ... logies.com

Too big to upload to forum...
Kaveh

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

Re: Automatically populating menu from list when user clicks

Post by Klaus » Sat Feb 09, 2019 6:08 pm

Hi Kaveh,

the trick is to put the menu changing "mousedown" handler into the script of the GROUP and not of the button(s)!
Bildschirmfoto 2019-02-09 um 18.05.53.jpg
Best

Klaus

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 175
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Automatically populating menu from list when user clicks

Post by kaveh1000 » Sat Feb 09, 2019 6:40 pm

Thank you Klaus. :-) It works!

I might have got there eventually, but would have taken a lot of trial and error. It sort of makes sense.
Kaveh

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

Re: Automatically populating menu from list when user clicks

Post by Klaus » Sat Feb 09, 2019 6:53 pm

I think this is because only the menubar GROUP on a Mac receives
the "mousedown" message, but not the buttons in it.

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 175
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Automatically populating menu from list when user clicks

Post by kaveh1000 » Sat Feb 09, 2019 7:05 pm

Yes, although when the menus are on the card as opposed to the system menubar, the button gets the message too.

Anyway, attached is the modified, working stack, modified as per your suggestion.
Attachments
Menu on the fly.livecode.zip
(1.08 KiB) Downloaded 5 times
Kaveh

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

Re: Automatically populating menu from list when user clicks

Post by Klaus » Sat Feb 09, 2019 7:39 pm

kaveh1000 wrote:
Sat Feb 09, 2019 7:05 pm
Yes, although when the menus are on the card as opposed to the system menubar, the button gets the message too.
Sure, but we were talking about the menubar in the Mac menubar, and not on a card. 8)

Post Reply

Return to “Talking LiveCode”