PDA

View Full Version : Radio Buttons (GUI)


Omini
08-06-2006, 10:29 PM
Can anyone show me an example of how the Radio Buttons work? (That's what they're called right? Radio Buttons? Like the buttons used at the bottom of a reply/new thread to choose the Post Icon?)

I've done a forum search--but couldn't find anything.

I searched the following pages:
http://wiki.graal.net/index.php/Creation/Dev/Script/Starting_Guide#NPCs_and_.27weapons.27
http://wiki.graal.net/index.php/Creation/Dev/Script/Client

Also with a search of "Radio buttons", "Radio" and "Radiobuttons" on the wikipedia.

I'd just like an example of how they would work, like so if you had 2 only one could be selected at a time (and what ever one is selected is read from a clientr.string). I just need the basics though, I can do the rest.

Yen
08-07-2006, 09:18 PM
Deal with them the same as a regular checkbox control.
Make a new GuiRadioCtrl for each button in the group.
Set their 'groupnum' variables to the same values. Only one button with the same groupnum can be checked at a time.
You can then read which is checked by going through each GUI and reading 'GUI.checked'

Omini
08-07-2006, 10:19 PM
I have no idea how to use checkboxes either. But would the GuiRadioCtrl look something like this?

new GuiRadioCtrl("RadioButton1") {
x = 20;
y = 20;
width = 32;
height = 32;
groupnum = 1;
}

new GuiRadioCtrl("RadioButton2") {
x = 60;
y = 20;
width = 32;
height = 32;
groupnum = 1;
}

new GuiRadioCtrl("RadioButton3") {
x = 20;
y = 60;
width = 32;
height = 32;
groupnum = 2;
}

new GuiRadioCtrl("RadioButton4") {
x = 60;
y = 60;
width = 32;
height = 32;
groupnum = 2;
}

Would that be it? Or is there anything else that I missed out?



Edit:

I've tried it and it works. Thanks for your help Yen.

Also - am I right in understanding that to read it, you've said GUI.checked? Would that be like this :

if (RadioButton1.checked == true) { }

Or is it something else?

Angel_Light
08-08-2006, 01:24 AM
Yeah that looks correct

Omini
08-09-2006, 08:17 PM
I still don't know how to read if the radio button is selected or not.

Here's the radio button part.

new GuiRadioCtrl("MsgOptionsRadio_Main1") {
x = 80;
y = 54;
width = 16;
height = 16;
groupnum = 1;
}

That's everything I have concerning that Radio Button (so if I'm missing a control or anything, let me know please)

Checking it, I've tried loads, but it can't read it.

I have it that reading it occurs after the player pushes a Button.

if (MsgOptionsRadio_Main1.select == true) {
echo("Correct");
} else {
echo("WTF?!");
}

Every time I try it, it just echos 'WTF?!'.

Please tell me what it is I'm missing.

ForgottenLegacy
08-10-2006, 02:17 PM
It's 'checked' or 'selected', 'select' is not an attribute.

Omini
08-10-2006, 08:06 PM
I believe I also tried those 2, but I'll try again.

*tries*

Ok so I've tried every one of the following and still no luck:
if ("MsgOptionsRadio_Main1".checked == "true") {
if (MsgOptionsRadio_Main1.checked == "true") {
if ("MsgOptionsRadio_Main1".checked == true) {
if (MsgOptionsRadio_Main1.checked == true) {
if (MsgOptionsRadio_Main1.selected == "true") {
if ("MsgOptionsRadio_Main1.selected" == "true") {
if (MsgOptionsRadio_Main1.selected == true) {
if ("MsgOptionsRadio_Main1.selected" == true) {



Any suggestions?

ForgottenLegacy
08-12-2006, 05:04 AM
You don't need to have the names of buttons in quotes, because it's all one word with no spaces and no mathematical symbols. 'true' is a constant defined as nonzero, and it's a keyword, so it doesn't need to be in quotes.

First off, paste the part of the script you have the part where you check the status of the radio button. Is it in a timeout loop? If not, is it in an onAction block? If not, then explain how you're doing it.

Omini
08-12-2006, 03:34 PM
You don't need to have the names of buttons in quotes, because it's all one word with no spaces and no mathematical symbols. 'true' is a constant defined as nonzero, and it's a keyword, so it doesn't need to be in quotes.

First off, paste the part of the script you have the part where you check the status of the radio button. Is it in a timeout loop? If not, is it in an onAction block? If not, then explain how you're doing it.


I don't have anything for it... but when I test the NPC and click on the radio button, it gets selected--so I assumed you didn't need anything for it.