That is because the mouse is never released, since showPauseMenu becomes false you don't update SUIT anymore, so it doesn't get a release event. Or that is what I think...
local suit = require ('suit')
pauseMenu = suit.new()
function love.update(dt)
if (showPauseMenu) then
pauseMenu.layout:reset((love.graphics.getWidth() / 2 ) - 150,(love.graphics.getHeight() / 2 ) - 45)
pauseMenu:Label("Pause", pauseMenu.layout:row(300,30))
if (pauseMenu:Button( "Resume", pauseMenu.layout:row() ).hit) then
showPauseMenu = false
--resume all gameplay logics
end
end
end
function love.draw()
--If you draw but pauseMenu when showPauseMenu is false you should get no UI
love.graphics.setBackgroundColor(0, 100, 200, 0.2)
pauseMenu:draw()
end
for i, person inipairs(everybody) do [tab]ifnot person.obey then person:setObey(true) end end
love.system.openURL(github.com/pablomayobre)
Yep, that seems to be the issue, it is working now.
I thought that the release event would be updated automatically when the mouse is hit, since it specifically does not check for the mouse to be hold down, but just hit. At least that is what I understand by the mouse being hit, a hold down is not intended.
Anyways, that means it is necessary to call the draw function every draw call of löve, even if we do not draw something? Does not sound to be the best practice.
Is there a way that I can manually update the button / the mouse event?
Think about it this way, if you don't call any SUIT function then how can SUIT run any code at all? If it can't run code then how do you expect it to detect that the mouse is not down anymore?
SUIT doesn't plug itself to LÖVE callbacks, and that is a good thing. You can actually control how everything works.
SUIT checks if there is something to draw if there is then it draws it, if it doesn't it just returns, so even if you call pause:draw() every frame, if you haven't added the buttons and labels in the update nothing will be drawn and the function will return inmediately.
SUIT draw function actually is two functions in one, one is the update function which actually updates all components and the other is the draw function which draws the elements to screen. SUIT combines them in order to offer a simpler API, you call one function that does everything.
And it works cause as I said, if nothing is added in the update then nothing is drawn to screen so there is no disadvantage on calling that function even when not needed
for i, person inipairs(everybody) do [tab]ifnot person.obey then person:setObey(true) end end
love.system.openURL(github.com/pablomayobre)
I've been trying on this SUIT, and I really like it. I'd love a small example of a custom widget though. I'm trying to hack together a scrollview with some text, but I'm having a hard time getting a custom widget working.
Is there a way to reduce the garbage production of SUIT? The bigdemo produces a few hundred kb in a few frames and I'm worried this might become a bottleneck with more involved GUIs on top of the engine.
Ashura wrote: ↑Wed Mar 15, 2017 4:41 pm
Seems to my the Github repository is dead, anyone interessted in continueing a fork?
There was a commit just 11 days ago. If a library runs fine there often just isn't a need to update its repo.
Just want to say thanks, "Immediate Mode" is a great way to insert or remove UI elements arbitrarily and I've been using SUIT to help build my own level editor.
Hello everyone. Is it just me or the isHovered(id) function is not working properly? I've been trying to make it work but I guess there must be something wrong since I was following documentation correctly. Here's my code. Any help would be really appreciated. Thank you!
io.stdout:setvbuf("no")
function love.load()
suit = require 'suit'
if suit.Button("Attack", 396,140, 80,25).hit then end
if suit.Button("Skill", 396,140+25, 80,25).hit then end
end
function love.update(dt)
if suit.Button("Attack", 396,140, 150,50).hit then end
if suit.Button("Skill", 396,140+60, 150,50).hit then end
print("Attack",suit:isHovered("Attack"))
print("Skill",suit:isHovered("Skill"))
end
function love.draw()
suit:draw()
end