Difference between revisions of "ImGui.Core:combo"

From GiderosMobile
(.deltaTime)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Displays an item in a list of items in the form of a combo box.
 
Displays an item in a list of items in the form of a combo box.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(number), (bool) = ImGui:combo(label,currentitem,items)
 
(number), (bool) = ImGui:combo(label,currentitem,items)
 
</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

Displays an item in a list of items in the form of a combo box. <syntaxhighlight lang="lua"> (number), (bool) = ImGui:combo(label,currentitem,items) </source>

Parameters

label: (string) the combo box label
currentitem: (number) the combo box current selected item
items: (table) the combo box list of items

Return values

Returns (number) the current item position in the items list
Returns (bool) whether the current item has been changed

Example

<syntaxhighlight lang="lua"> require "ImGui"

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

local window01 = true local fruits = {"apple", "banana", "orange", "apricot"} local currentfruit = 2 -- orange (0 based table)

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") if window01 then imgui:text("Hello Dear ImGui!") currentfruit, hasfruitchanged = imgui:combo("king of combo2", currentfruit, fruits) if hasfruitchanged then print(fruits[currentfruit+1]) end end -- 3 we end the frame and render to screen imgui:endFrame() imgui:render() end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) </source>