Difference between revisions of "ImGui.Core:inputInt"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2020.9<br/> '''Class:''' ImGui<br/> === Description === Sets an input int field with a plus and a minus button. <source lang="lua...")
 
Line 4: Line 4:
  
 
=== Description ===
 
=== Description ===
Sets an input int field with a plus and a minus button.
+
Sets an input int field with a plus and a minus button when step is different than 0.
 
<source lang="lua">
 
<source lang="lua">
 
(number), (bool) = ImGui:inputInt(label, value, [step=0, step_fast=0, ImGuiInputTextFlags=0])
 
(number), (bool) = ImGui:inputInt(label, value, [step=0, step_fast=0, ImGuiInputTextFlags=0])

Revision as of 22:37, 2 April 2021

Available since: Gideros 2020.9
Class: ImGui

Description

Sets an input int field with a plus and a minus button when step is different than 0.

(number), (bool) = ImGui:inputInt(label, value, [step=0, step_fast=0, ImGuiInputTextFlags=0])

Parameters

label: (string) the label
value: (number) the value to be displayed
step: (number) the step to increment/decrement the displayed value
step_fast: (number) the speed at which to increment/decrement the displayed value when button is pressed
ImGuiInputTextFlags : (number) the input text flag

Return values

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

Example

require "ImGui"

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

local window01 = true
local value = 10

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") -- no close button (X)
	if window01 then -- the variable is false when window is collapsed
		imgui:text("Hello Dear ImGui!")
		local isChanged = false
		value, isChanged = imgui:inputInt("some value", value, 1, 2, 0)
		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)