flamendless / Slab

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

Input request type message dialog #54

Closed chicogamedev closed 3 years ago

chicogamedev commented 4 years ago

Hi,

Slab is a wonderful lib that I really enjoy working with.

I've created my own Input request message dialog, like a simple Text that ask for a value and a simple text Input.

But there is a small flaw in the Input object. In this case I ask to get the focus in my Input using : Slab.SetInputFocus(Id)

And this is working but here it comes : because it is a dialog I want that the value in the Input is always clear at opening. So I use the Text option. and I make sure that the var used is empty :

if (Slab.Input("ProjectName", { Text = self.newProjectName, W = 250 })) then self.newProjectName = Slab.GetInputText() end

So for sure self.newProjectName is == "" when I enter my dialog. But because I give the focus to the object Slab is not able to clear the Input (I found the line in the Input.lua file of Slab :

if Focused ~= Instance then if Options.MultiLine and #Options.Text ~= #Instance.Text then Instance.Lines = nil end Instance.Text = Options.Text == nil and Instance.Text or Options.Text end

(Around line 955) (edit : So sorry for the code block can't get it working :( )

it put me on the tracks of the focus problem.

So my solution for now is to wait for the user to press "tab" to give the focus to the input field.

Am I missing something ? Should I change the way I give the focus ?

Thanks for help and thanks for this amazing library.

coding-jackalope commented 4 years ago

Hi @chicogamedev, thanks for reporting the issue. I'll take a look into this for the next upcoming patch release.