Dropdown with Multiple Selections?

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

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Dropdown with Multiple Selections?

Post by cmhjon » Thu Mar 11, 2021 4:17 pm

Hi all,

I would like to use a drop down menu style control that allows multiple selections. Is there a control that allows this? I've tried all of the 'menu' controls and none seem to be able to do this?

Thank you,
Jon :)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Dropdown with Multiple Selections?

Post by richmond62 » Thu Mar 11, 2021 4:25 pm

Sounds a bit unlikely.

Although you could have a listField which stacks up menu selections . . .

-
SShot 2021-03-11 at 18.14.55.png
-

Code: Select all

on mouseDown
   put the fontNames into me
   sort lines of me ascending international
end mouseDown

on menuPick XXX
   put 1 into LYNE
   repeat until LYNE > 1000000
      if line LYNE of fld "MyFontz" is empty then
         put XXX into line LYNE of fld "MyFontz"
         put 1000005 into LYNE
      else
         add 1 to LYNE
      end if
      end repeat
      end menuPick
Attachments
MULTI-STOREY CAR PARK.livecode.zip
Here's the stack.
(6.04 KiB) Downloaded 114 times

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

Re: Dropdown with Multiple Selections?

Post by dunbarx » Thu Mar 11, 2021 7:54 pm

I think Richmond is correct.

These sorts of gadgets are drawn by the OS, and are not designed for what you want. You need to kludge LC itself. I have not seen Richmonds stack, but I bet it warrants examination.

Craig

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

Re: Dropdown with Multiple Selections?

Post by Klaus » Thu Mar 11, 2021 8:09 pm

@ Mr. Cumbersome
What about just:

Code: Select all

on menupick xxx
   if fld "YourFonz" = EMPTY then
      put xxx into fld "YourFonz"
   else
      put CR & xxx AFTER fld "YourFonz"
   end if
end menupick
8)


Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Dropdown with Multiple Selections?

Post by richmond62 » Thu Mar 11, 2021 8:19 pm

OK, @Mr Short, F*t and Ug** 8)

Your code may be shorter, but it may also be more difficult for other coders to "unpack".

Also, as a person who has repaired a bailer with barbed wire . . .
-
bailer.jpeg
bailer.jpeg (10.9 KiB) Viewed 5110 times
-
. . . I am interested in getting the job done, even if "only" with barbed wire.

So do not consider that you can do something in a shorter "more elegant" (highly subjective) way as
somehow virtuous.

As I very rarely program on my BBC Micro with 32 Kb RAM I do NOT always feels an urge
to program in a minimalistic, elegant way.

Also, as I pointed out elsewhere today,
most of my code samples are put together in 5-10 minute breaks between online ZOOM classes.

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

Re: Dropdown with Multiple Selections?

Post by Klaus » Thu Mar 11, 2021 8:28 pm

richmond62 wrote:
Thu Mar 11, 2021 8:19 pm
Your code may be shorter, but it may also be more difficult for other coders to "unpack".
I HIGHLY doubt that! :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Dropdown with Multiple Selections?

Post by richmond62 » Thu Mar 11, 2021 8:47 pm

I HIGHLY doubt that!
John Stuart Mill may have said to Herbert Spencer,
"I disagree with everything you say, but I will always support your right to say it."

Be eternally grateful you do not have to snatch coding "snacks" between teaching ZOOM classes.
-
SShot 2021-03-11 at 21.48.58.png

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Dropdown with Multiple Selections?

Post by stam » Thu Mar 11, 2021 9:11 pm

As Richmond says above, a listField is the probably the easiest way to do this.
If you need more inspiration you can check out a quick comboBox replacement i put together as a group object (what Craig would no doubt call a 'kludge' ;)).

I wasn't happy with the default comboBox, as there was no 'type ahead' searching of values and no way for the user to add/remove values in runtime, no arrow key navigation, etc, so i rolled my own and it works very well (so far!). Basically it's a group consisting of a a text field, listField, popup and an invisible rect to hold it all together and resize the group easier in IDE.
The listField simulates the popup bit of the combobox.

You can probably modify this to whatever suits your needs - download it from my github here: skComboBox

Hope that helps
Stam

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

Re: Dropdown with Multiple Selections?

Post by dunbarx » Thu Mar 11, 2021 10:00 pm

Klaus.
on menupick xxx
if fld "YourFonz" = EMPTY then
put xxx into fld "YourFonz"
else
put CR & xxx AFTER fld "YourFonz"
end if
end menupick
how does this present a multi-line selectable list of menuItems?

Only a kludge, like a listField made to look and act like such a list will work here.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Dropdown with Multiple Selections?

Post by richmond62 » Thu Mar 11, 2021 10:12 pm

how does this present a multi-line selectable list of menuItems?
It doesn't.

But the OP did not ask for that as far as I can see.

What I believe (and the OP should feel 100% free to correct me if I'm wrong)
is that the OP wanted the ability to make several selections from a drop-down menu.

My code (and Klaus's) allows an end-user to make multiple selections which are then stored in a listField.

Having the multiple selections listed now allows them to be acted on.

I cannot see this sort of thing being possible at all:
-
multiFantasy.jpg

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

Re: Dropdown with Multiple Selections?

Post by bogs » Thu Mar 11, 2021 10:24 pm

richmond62 wrote:
Thu Mar 11, 2021 10:12 pm
how does this present a multi-line selectable list of menuItems?
It doesn't.

But the OP did not ask for that as far as I can see.

What I believe (and the OP should feel 100% free to correct me if I'm wrong)
is that the OP wanted the ability to make several selections from a drop-down menu.

My code (and Klaus's) allows an end-user to make multiple selections which are then stored in a listField.

Having the mulitple selections listed now allows them to be acted on.
Wait.....what? Image

Anyway, I don't have any input on this other than to say I don't see how it would be accomplished short of grouping a button and list field, and setting the list field to expand/contract when done making selections.
Image

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

Re: Dropdown with Multiple Selections?

Post by dunbarx » Thu Mar 11, 2021 10:25 pm

I have no idea what youse guys are talking about.

How does any of this present a multi-line pullDown of menuItems, so that the user can select one or more of them?

What does this field "yourFonz" have to do with anything , except to append a single selection after its contents?

What is needed is a multi-line capable list field, preset to magically appear on mouseDown over and below an appropriately prepared button that looks like a pulldown.

What am I, or you, missing here?

Craig

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

Re: Dropdown with Multiple Selections?

Post by bogs » Thu Mar 11, 2021 10:32 pm

Far as I can tell your not missing anything, that was what I just said up there heh.
Image

Davidv
Posts: 77
Joined: Sun Apr 09, 2006 1:51 am
Location: Australia

Re: Dropdown with Multiple Selections?

Post by Davidv » Thu Mar 11, 2021 10:59 pm

I am not aware of multi-line selection from a drop-down (or similar) menu in any of the obvious OS, so wonder at the OP's desire to introduce such a thing here. On the other hand, multi-line selection in a field is commonplace.

What is the case here, the reasons to shift normal operating paradigms for users?

How to do it seems to me of only academic interest, perhaps not a type that should be touched, or perhaps we are going to revolutionise the thinking of Apple, Microsoft, and a million penguins. :)

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

Re: Dropdown with Multiple Selections?

Post by bogs » Thu Mar 11, 2021 11:04 pm

Well, speaking just for me, just asking the question is good enough. It isn't like I think everything that comes out of Redmond is gold of the realm, the same goes for Apples guidelines. Even some parts of 'nix'en interfaces leave me wondering :roll:

So, if someone wants a purple headed oxern to pull their cart, who am I to question it ? I just start looking for purple headed oxern :twisted:
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”