ImGui.Core:radioButton

Available since: Gideros 2020.9
Class: ImGui

Description

Creates one or several radio buttons.

(number), (bool) = ImGui:radioButton(text, value1, value2)

Parameters

text: (string) the radio button text
value1: (number) the current active value (should be the same as number)
value2: (number) the value the number will change to

Return values

Returns (number) the new current number value
Returns (bool) whether a value has changed

Example

require "ImGui"

local imgui = ImGui.new()
stage:addChild(imgui)

local window01 = true
local value = 1 -- default will be radio button B

function onEnterFrame(e)
	-- 1 we start ImGui
	imgui:newFrame(e.deltaTime)
	-- 2 we add some child windows and build our GUI
	window01 = imgui:beginWindow("Window 01") -- no close button (X)
	if window01 then -- the variable is false when window is collapsed
		imgui:text("Hello Dear ImGui!") -- we add a text element to our GUI
		local ischanged = false
		value, ischanged = imgui:radioButton("A", value, 0) imgui:sameLine()
		if ischanged then print(value) end
		value, ischanged = imgui:radioButton("B", value, 1) imgui:sameLine()
		if ischanged then print(value) end
		value, ischanged = imgui:radioButton("C", value, 2) imgui:sameLine()
		if ischanged then print(value) end
	end
	-- 3 we end the frame and render to screen
	imgui:endFrame()
	imgui:render()
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)