Difference between revisions of "ImGui.Core:radioButton"

From GiderosMobile
(fixed typo isChanged to ischanged)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Creates one or several radio buttons.
 
Creates one or several radio buttons.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(number), (bool) = ImGui:radioButton(text, value1, value2)
 
(number), (bool) = ImGui:radioButton(text, value1, value2)
 
</source>
 
</source>
Line 19: Line 19:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "ImGui"
 
require "ImGui"
  

Revision as of 15:28, 13 July 2023

Available since: Gideros 2020.9
Class: ImGui

Description

Creates one or several radio buttons. <syntaxhighlight lang="lua"> (number), (bool) = ImGui:radioButton(text, value1, value2) </source>

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

<syntaxhighlight lang="lua"> 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) </source>