ImGui.Core:inputTextWithHint

From GiderosMobile

Available since: Gideros 2020.9
Class: ImGui

Description

Sets an input text field with a hint when text field is empty.

(string), (bool) = ImGui:inputTextWithHint(label, text, hint, bufferSize, [ImGuiInputTextFlags=0])

Parameters

label: (string) the label
text: (string) the text to be displayed
hint: (string) a hint when no text is displayed
bufferSize: (number) sets a buffer size
ImGuiInputTextFlags : (number) see ImGui.CONST.InputTextFlags

Return values

Returns (string) 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 text = ""

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
		text, isChanged = imgui:inputTextWithHint("text", text, "some hint", 2*256, 0)
		if isChanged then print(text) end
	end
	-- 3 we end the frame and render to screen
	imgui:endFrame()
	imgui:render()
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)