Page 1 of 1

gui - radio button and sprite button

Posted: Fri Dec 02, 2016 10:14 am
by sore68
Hi~
I make gui - radio buttons
radio.png
radio.png (62.29 KiB) Viewed 2996 times
and code

Code: Select all

frame = player.gui.left.add{type="frame", name="at_request_button"}
frame_table = frame.add{type="table", name="at_request_button", colspan = 1}
frame_table.add{type = "radiobutton", name = "at_request_all_radio", state = false, caption = "Change the request slot of the selected all turrets at the bottom."}
frame_table.add{type = "radiobutton", name = "at_request_near_radio", state = false, caption = "Change the request slot of the selected nearby turrets at the bottom."}
...
My problem is select radio button. I want select only one, not more...
Can I bind radio buttons? of Is it possible only through on_gui_click or on_gui_checked_state_changed?



----------
Oh delete table and add direction in frame, It does the action I want. :D
hmm.. Not change;;; just action true/false code... :(

Re: gui - radio button

Posted: Fri Dec 02, 2016 10:58 am
by prg
From the documentation:
"radiobutton": Identical to checkbox except circular.
Seems like you need to uncheck them manually.

Re: gui - radio button

Posted: Fri Dec 02, 2016 12:35 pm
by Klonan
prg wrote:From the documentation:
"radiobutton": Identical to checkbox except circular.
Seems like you need to uncheck them manually.
Yep they will need to be unchecked manuall... which is each:

LuaGuiElement.state = false

Re: gui - radio button

Posted: Fri Dec 02, 2016 1:55 pm
by sore68
prg wrote:...
Klonan wrote:...

Thanks for letting me know! :D

Re: gui - radio button

Posted: Fri Dec 02, 2016 2:46 pm
by steinio
You could make a suggestion for adding a group tag for radiobuttons. Every item with the same group name can only have one of the group selected and disables all other items of the group automatically.

Greetings steinio

Re: gui - radio button

Posted: Fri Dec 02, 2016 3:05 pm
by sore68
steinio wrote:You could make a suggestion for adding a group tag for radiobuttons. Every item with the same group name can only have one of the group selected and disables all other items of the group automatically.

Greetings steinio

Oh! That's what I was looking for!
Can you explain a bit more about [adding a group tag]???

Re: gui - radio button

Posted: Fri Dec 02, 2016 3:16 pm
by sore68
A new problem has come to me.
sb.png
sb.png (139.41 KiB) Viewed 2955 times

Code: Select all

frame.add{type = "sprite-button", name = string.sub(frame.name, 1, 15)..ammo_name[1], sprite = "item/"..ammo_name[1]}
s.png
s.png (331.66 KiB) Viewed 2955 times

Code: Select all

frame.add{type = "sprite", name = string.sub(frame.name, 1, 15)..ammo_name[1], sprite = "item/"..ammo_name[1]}

Above is when using the sprite button, and below is when using the sprite.
Does the sprite of the sprite button have a different meaning??

Re: gui - radio button and sprite button

Posted: Fri Dec 02, 2016 11:39 pm
by Earendel
The sprite in a sprite button does not cause the button to expand. Try adding style="my-button-style" to your button and define the style:

Code: Select all

data.raw["gui-style"]["default"]["my-button-style"] =
{
	type = "button_style",
	parent = "button_style",
	minimal_width = 32,
	minimal_height = 32,
	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,
}

Re: gui - radio button and sprite button

Posted: Sat Dec 03, 2016 8:23 am
by sore68
Earendel wrote:The sprite in a sprite button does not cause the button to expand. Try adding style="my-button-style" to your button and define the style:

Code: Select all

data.raw["gui-style"]["default"]["my-button-style"] =
{
	type = "button_style",
	parent = "button_style",
	minimal_width = 32,
	minimal_height = 32,
	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,
}
OH!! Thanks for providing me with a guide. :D :D