Fixed raygui edit mode selection.

This commit is contained in:
jussi
2023-11-24 22:57:00 +02:00
parent a1887aa866
commit b3a956cff2
4 changed files with 28 additions and 11 deletions

View File

@@ -24,6 +24,7 @@ DETAILED CHANGES:
- ADDED: LoadSoundAlias and UnloadSoundAlias. - ADDED: LoadSoundAlias and UnloadSoundAlias.
- ADDED: GetApplicationDirectory. - ADDED: GetApplicationDirectory.
- FIXED: Snake example after Vector2Angle change. - FIXED: Snake example after Vector2Angle change.
- FIXED: Raygui edit mode selection.
------------------------------------------------------------------------ ------------------------------------------------------------------------
Release: ReiLua version 0.6.0 Using Raylib 4.5 Release: ReiLua version 0.6.0 Using Raylib 4.5

View File

@@ -3,8 +3,6 @@ Current {
Backlog { Backlog {
* Platform specific API documentation. * Platform specific API documentation.
* Raylibgui.
* Fix textbox focus.
* Platform desktop SDL. * Platform desktop SDL.
* Text input not working on gui. Could this be Raylib issue? * Text input not working on gui. Could this be Raylib issue?
* Haptic functions. * Haptic functions.

View File

@@ -101,6 +101,13 @@ function RL.init()
false, false,
function( self ) print( "Set text "..self.text ) end 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( local slider = Raygui.Slider:new(
Rect:new( 50, 500, 256, 32 ), Rect:new( 50, 500, 256, 32 ),
"min", "min",
@@ -255,14 +262,6 @@ function RL.init()
end end
function RL.process( delta ) 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() Raygui.process()
end end

View File

@@ -55,6 +55,7 @@ local Raygui = {
dragging = nil, dragging = nil,
grabPos = Vec2:new(), grabPos = Vec2:new(),
scrolling = false, scrolling = false,
textEdit = false,
} }
function Raygui.process() function Raygui.process()
@@ -111,7 +112,7 @@ function Raygui.drag( element )
end end
function Raygui.draw() function Raygui.draw()
if not Raygui.scrolling then if not Raygui.scrolling and not Raygui.textEdit then
RL.GuiLock() RL.GuiLock()
elseif RL.IsMouseButtonReleased( RL.MOUSE_BUTTON_LEFT ) then elseif RL.IsMouseButtonReleased( RL.MOUSE_BUTTON_LEFT ) then
Raygui.scrolling = false Raygui.scrolling = false
@@ -158,6 +159,21 @@ function Raygui.remove( element )
end end
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 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 ) result, self.value = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
if result == 1 then if result == 1 then
Raygui.editMode( self.editMode )
self.editMode = not self.editMode self.editMode = not self.editMode
end 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 ) result, self.value = RL.GuiValueBox( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
if result == 1 then if result == 1 then
Raygui.editMode( self.editMode )
self.editMode = not self.editMode self.editMode = not self.editMode
end end
@@ -983,6 +1001,7 @@ function TextBox:draw()
end end
if result == 1 then if result == 1 then
Raygui.editMode( self.editMode )
self.editMode = not self.editMode self.editMode = not self.editMode
if not self.editMode and self.callback ~= nil then if not self.editMode and self.callback ~= nil then