Difference between revisions of "ImGui.Core:colorButton"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2020.9<br/> '''Class:''' ImGui<br/> === Description === Displays a simple color button. <source lang="lua"> (bool) = ImGui:colorB...")
 
Line 11: Line 11:
 
=== Parameters ===
 
=== Parameters ===
 
'''string_id''': (string) the button ID<br/>
 
'''string_id''': (string) the button ID<br/>
'''color''': (number) the button color<br/>
+
'''color''': (number) the button color in hexadecimal<br/>
 
'''alpha''': (number) the buttton alpha<br/>
 
'''alpha''': (number) the buttton alpha<br/>
 
'''width''': (number) the button width<br/>
 
'''width''': (number) the button width<br/>

Revision as of 01:46, 23 October 2021

Available since: Gideros 2020.9
Class: ImGui

Description

Displays a simple color button.

(bool) = ImGui:colorButton(string_id, color, alpha, [width=0, height=0, ImGuiColorEditFlags=0])

Parameters

string_id: (string) the button ID
color: (number) the button color in hexadecimal
alpha: (number) the buttton alpha
width: (number) the button width
height: (number) the button height
ImGuiColorEditFlags: (number) one of ImGui color edit flags

Return values

Returns (bool) whether the button was pressed

Example

require "ImGui"

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

local window01 = true
local hexcolor = 0x00ff00
local alpha = 0.5

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
		isChanged = imgui:colorButton("button ID", hexcolor, alpha, 48, 48, 0)
		if isChanged then print(hexcolor, alpha) end
	end
	-- 3 we end the frame and render to screen
	imgui:endFrame()
	imgui:render()
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)