Skip to content

Popup improvements #6

@DoubleNom

Description

@DoubleNom

Follow up to an internal discussion on how to imprive popups in order to have better input/ouputs control.

Variable Text

Add a function optional parameter to text, allowing to update the text value on the fly

When function returns nil, no change. When function returns a text, update the widget text

This will be mainly useful when doing loading operations or for checking text inputs

Popup("MyPopup")
  :Text("Titre", {routine=function() return tostring(os.time()) end}) -- Start by showing "Titre", then display time since program was started
  :Show()

InputText Routine

It is currently not possible to get the value of an input text.
One way to get it would to add a routine function to report the current value of the input text

Popup("MyPopup"):Input("MyInput", {routine=function(text) print(text) end}):Show()

Show returns

Currently, shows return nothing.

It could instead return a table with the value of all input widgets such as Button, Text input or future input widgets.

When popup is consumed, it would list all of its elements for their return value. Widget that do not return a value are discarded

Returned table would then provided Input widgets in order, but also propose a map style

local results = Popup("MyPopup")
  :Text("Please inputs your stuff")
  :InputText("MyInputText")
  :Button("Ok", function() end, {consume=true})
  :Show()

print(results[1]) -- print InputText
print(results.Ok) -- print Ok state when consumed

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions