flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
286 stars 25 forks source link

Cannot select scrolled area of listbox #159

Closed NoRuBal closed 1 year ago

NoRuBal commented 1 year ago

If listbox has more list items than listbox can display, scrollbar appears. User can scroll down, but if user clicked list items on scrolled area, items won't be selected. Issue only can be reproduced on master branch. It won't be reproduced on latest stable release(0.9.0). Please check an image below.

listbox_bug

Code(main.lua)

Slab = require "slab"
local Selected = nil

function love.load()
    Slab.Initialize(args)
end

function love.draw()
    Slab.Draw()
end

function love.update(dt)
    Slab.Update(dt)

    Slab.BeginWindow('ListBox', {Title = "List Box", AutoSizeWindow = false})

    Slab.BeginListBox('ListBoxExample')
    for I = 1, 10, 1 do
        Slab.BeginListBoxItem('ListBoxExample_Item_' .. I, {Selected = Selected == I})
        Slab.Text("Item " .. I)

        if Slab.IsListBoxItemClicked() then
            Selected = I
        end

        Slab.EndListBoxItem()
    end
    Slab.EndListBox()

    Slab.EndWindow()
end

.love file: Listbox.zip

flamendless commented 1 year ago

@NoRuBal fix has been pushed. Thank you