Fixed raygui edit mode selection.
This commit is contained in:
@@ -101,6 +101,13 @@ function RL.init()
|
||||
false,
|
||||
function( self ) print( "Set text "..self.text ) end
|
||||
)
|
||||
local textbox2 = Raygui.TextBox:new(
|
||||
Rect:new( 32, 380, 256, 32 ),
|
||||
"Name",
|
||||
32,
|
||||
false,
|
||||
function( self ) print( "Set text "..self.text ) end
|
||||
)
|
||||
local slider = Raygui.Slider:new(
|
||||
Rect:new( 50, 500, 256, 32 ),
|
||||
"min",
|
||||
@@ -255,14 +262,6 @@ function RL.init()
|
||||
end
|
||||
|
||||
function RL.process( delta )
|
||||
if RL.IsKeyPressed( RL.KEY_R ) then
|
||||
Raygui.set2Top( windowbox )
|
||||
end
|
||||
|
||||
if RL.IsKeyPressed( RL.KEY_F ) then
|
||||
Raygui.set2Back( windowbox )
|
||||
end
|
||||
|
||||
Raygui.process()
|
||||
end
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ local Raygui = {
|
||||
dragging = nil,
|
||||
grabPos = Vec2:new(),
|
||||
scrolling = false,
|
||||
textEdit = false,
|
||||
}
|
||||
|
||||
function Raygui.process()
|
||||
@@ -111,7 +112,7 @@ function Raygui.drag( element )
|
||||
end
|
||||
|
||||
function Raygui.draw()
|
||||
if not Raygui.scrolling then
|
||||
if not Raygui.scrolling and not Raygui.textEdit then
|
||||
RL.GuiLock()
|
||||
elseif RL.IsMouseButtonReleased( RL.MOUSE_BUTTON_LEFT ) then
|
||||
Raygui.scrolling = false
|
||||
@@ -158,6 +159,21 @@ function Raygui.remove( element )
|
||||
end
|
||||
end
|
||||
|
||||
function Raygui.editMode( editMode )
|
||||
if not editMode then
|
||||
for _, element in ipairs( Raygui.elements ) do
|
||||
if element.editMode then
|
||||
element.editMode = false
|
||||
|
||||
if element.callback ~= nil then
|
||||
element.callback( element )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Raygui.textEdit = not editMode
|
||||
end
|
||||
|
||||
--[[
|
||||
Container/separator controls, useful for controls organization
|
||||
]]--
|
||||
@@ -881,6 +897,7 @@ function Spinner:draw()
|
||||
result, self.value = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
||||
|
||||
if result == 1 then
|
||||
Raygui.editMode( self.editMode )
|
||||
self.editMode = not self.editMode
|
||||
end
|
||||
|
||||
@@ -929,6 +946,7 @@ function ValueBox:draw()
|
||||
result, self.value = RL.GuiValueBox( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
||||
|
||||
if result == 1 then
|
||||
Raygui.editMode( self.editMode )
|
||||
self.editMode = not self.editMode
|
||||
end
|
||||
|
||||
@@ -983,6 +1001,7 @@ function TextBox:draw()
|
||||
end
|
||||
|
||||
if result == 1 then
|
||||
Raygui.editMode( self.editMode )
|
||||
self.editMode = not self.editMode
|
||||
|
||||
if not self.editMode and self.callback ~= nil then
|
||||
|
||||
Reference in New Issue
Block a user