Page 11 of 11

Re: Slab - An Immediate Mode GUI Library In Lua

Posted: Tue Jan 14, 2025 5:50 am
by yetneverdone
zazabar wrote: Sun Jan 12, 2025 7:34 pm Hey, great lib!

I am trying to figure out how to "consume" the input from the slab ui, so that when the user mouse clicks on the ui it will not call game logic related to mouse click.

example:
1. ui button
2. click on the ui button
3. have gameplay logic on love.mousepressed

ps:
I've dontInterceptEventHandlers = true and the whole code is:

Code: Select all

function love.mousepressed(x, y, button, istouch, presses)
    Slab.OnMousePressed(x, y, button, istouch, presses) -- how do I know that this was actually performed over a window?
    -- if Slab "consumes" the same actions.move_command button then it will early return here
    if actions.move_command == button then
        self.input.move_command = true
    end
end
You handle that by either `break` or `return` or using `if` statement to determine whether to continue or not based on the result of the API/input.

As for the mouse input inside the window, you can check using the coordinates/parameters `x` and `y` in the function. If by "window" you mean Slab widget, you can check the functions here https://github.com/flamendless/Slab/wiki/Interaction accordingly.