create option button

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

Post Reply
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

create option button

Post by Da_Elf » Sat Sep 20, 2014 2:39 pm

I've gone through about 4 pages in search trying to find this

Code: Select all

on mouseUp
   create button "test"
   set the menuMode of it to option
   set showName of it to false
   set text of it to "hello"&return&"goodbye"
   set menuLines of it to 2
end mouseUp
i got the set the menuMode thing from the dictionary however it doesnt change the button from pushbutton to option menu

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: create option button

Post by jmburnod » Sat Sep 20, 2014 3:37 pm

Hi,

Just add the btn style like this

Code: Select all

on mouseUp
   create button "test"
   set the style of it to popup -- add 
    set the menuMode of it to option
   set showName of it to false
   set text of it to "hello"&return&"goodbye"
   set menuLines of it to 2
end mouseUp
Best regards
Jean-Marc
https://alternatic.ch

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: create option button

Post by Da_Elf » Sat Sep 20, 2014 4:36 pm

awesome thanks

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

Re: create option button

Post by dunbarx » Sun Sep 21, 2014 1:55 am

Here is a trick, so that you do not need to know which properties are required to set up a control.

Make an option button by dragging from the tool palette. Then:

set the properties of the templateButton to the properties of btn "yourBrandNewOptionButton"

Now when you make a new one using the "create" command, the desired style will be preset.

Craig Newman

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: create option button

Post by Da_Elf » Sun Sep 21, 2014 1:29 pm

actually there are 3 main buttons i will be making lots of duplicates of. Ive created them with all of their properties that i need. Now i just use "clone" and rename the clone to what i need

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

Re: create option button

Post by dunbarx » Sun Sep 21, 2014 3:24 pm

Hi.

Well and good.

If you think about it, you are using your "parent" button as a template. Same concept, but the templateButton is global; that is, you can create new controls anywhere, not just on the current card. Also, you can change the properties of the templateButton from anywhere. Or nowhere, for example, from the message box

Craig

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: create option button

Post by Da_Elf » Sun Sep 21, 2014 3:30 pm

i never could figure out how to setup template stuff. The dictionary and google were no help. i came across clone when trying to copy a substack since i couldnt figure out templateStack.

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

Re: create option button

Post by dunbarx » Mon Sep 22, 2014 2:51 am

Take a few moments to do this. Make two buttons. In the first, place this into its script:

Code: Select all

on mouseUp
   set the properties of the templateButton to the properties of btn 2
   create btn "xx"
end mouseUp
Now change btn 2 in any way you want. Color it, change its rect, border, whatever. Now click on btn 1.

The new button will overlie the one you manhandled, It should, correct? After all, the new button "xx" will inherit all the properties of btn 2, including its rect. Drag it off of the back of btn 2. It is as simple as that. The templateButton has been characterized according to the properties of btn 2. Now normally, you would only set a few properties, but that is a detail. This template can be used anywhere to create "clones" of iteself, possessing the properties you determine for it.

Note the caveat in the dictionary about locking messages. I do not think this is valid, since the template retains its properties whether or not I lock messages after multiple "create" actions. Not sure about this issue.

Craig

Post Reply