flamendless / Slab

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

Menu within Window gets overwritten by multi-line input #161

Closed akkartik closed 11 months ago

akkartik commented 11 months ago

Consider the following test program:

function love.load(args)
  love.graphics.setBackgroundColor(0.4, 0.88, 1.0)
  Slab.Initialize(args)
end

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

function love.update(dt)
  Slab.Update(dt)
  Slab.BeginWindow('main')
  if Slab.BeginMenuBar() then
    if Slab.BeginMenu("File") then
      Slab.EndMenu()
    end
    Slab.EndMenuBar()
  end
  if Slab.Input('input', {Text=Text, MultiLine=true, MultiLineW=200, H=60}) then
    Text = Slab.GetInputText()
  end
  Slab.EndWindow()
end

When I run this I see a menu and input as expected. However, if I click on the text input box, the menu disappears. The input seems to overwrite the menu.

flamendless commented 11 months ago

It's behaving as it should.

You put the input inside the scope of the menu bar, that is why it is rendering there.

akkartik commented 11 months ago

Is there a better way to phrase my example so the menu doesn't overlap the input?

flamendless commented 11 months ago

Put the Slab.Input outside the BeginMenuBar context, and perhaps put it in a window context.

Also, BeginMenuBar and Menu can be outside a window context (not inside the scope of BeginWindow and its pair EndWindow)

akkartik commented 11 months ago

I'm confused. Isn't my Slab.Input inside Slab.BeginWindow()/Slab.EndWindow() and outside Slab.BeginMenubar()/Slab.EndMenuBar()?

(I do want the menu bar inside a Window at the moment..)

flamendless commented 11 months ago

The menu bar is there, it's just getting behind the text input when you click it because it focuses on the text input.