ImGui.Core:combo

From GiderosMobile
Revision as of 10:11, 27 March 2021 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2020.9<br/> '''Class:''' ImGui<br/> === Description === Displays an item in a list in form of a combo box. <source lang="lua"> (n...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2020.9
Class: ImGui

Description

Displays an item in a list in form of a combo box.

(number), (bool) = ImGui:combo(label,currentitem,items)

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

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)
	-- 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)