Page 1 of 1

create option button

Posted: Sat Sep 20, 2014 2:39 pm
by Da_Elf
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

Re: create option button

Posted: Sat Sep 20, 2014 3:37 pm
by jmburnod
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

Re: create option button

Posted: Sat Sep 20, 2014 4:36 pm
by Da_Elf
awesome thanks

Re: create option button

Posted: Sun Sep 21, 2014 1:55 am
by dunbarx
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

Re: create option button

Posted: Sun Sep 21, 2014 1:29 pm
by Da_Elf
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

Re: create option button

Posted: Sun Sep 21, 2014 3:24 pm
by dunbarx
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

Re: create option button

Posted: Sun Sep 21, 2014 3:30 pm
by Da_Elf
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.

Re: create option button

Posted: Mon Sep 22, 2014 2:51 am
by dunbarx
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