From dfd67d28030009d69c2f92938fdaabf64054b346 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 16 Jan 2014 20:47:43 -0500 Subject: Added support for multiple entry boxes in inputdialogs. Requires latest gtdialog hg (r67). --- core/.ui.dialogs.luadoc | 36 ++++++++++++++++++++++++++++-------- core/ui.lua | 6 +++++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/core/.ui.dialogs.luadoc b/core/.ui.dialogs.luadoc index 002fac47..fc943eaa 100644 --- a/core/.ui.dialogs.luadoc +++ b/core/.ui.dialogs.luadoc @@ -113,8 +113,13 @@ function yesno_msgbox(options) end -- @param options Table of key-value option pairs for the input box. -- -- * `title`: The dialog's title text. --- * `informative_text`: The dialog's main message text. --- * `text`: The dialog's initial input text. +-- * `informative_text`: The dialog's main message text. If the value is a +-- table, the first table value is the main message text and any subsequent +-- values are used as the labels for multiple entry boxes. Providing a +-- single label has no effect. +-- * `text`: The dialog's initial input text. If the value is a table, the +-- table values are used to populate the multiple entry boxes defined by +-- `informative_text`. -- * `button1`: The right-most button's label. The default value is -- `_L['_OK']`. -- * `button2`: The middle button's label. @@ -145,8 +150,13 @@ function inputbox(options) end -- @param options Table of key-value option pairs for the input box. -- -- * `title`: The dialog's title text. --- * `informative_text`: The dialog's main message text. --- * `text`: The dialog's initial input text. +-- * `informative_text`: The dialog's main message text. If the value is a +-- table, the first table value is the main message text and any subsequent +-- values are used as the labels for multiple entry boxes. Providing a +-- single label has no effect. +-- * `text`: The dialog's initial input text. If the value is a table, the +-- table values are used to populate the multiple entry boxes defined by +-- `informative_text`. -- * `no_cancel`: Do not display the "Cancel" button. The default value is -- `false`. -- * `string_output`: Return the selected button's label or the dialog's exit @@ -171,8 +181,13 @@ function standard_inputbox(options) end -- @param options Table of key-value option pairs for the input box. -- -- * `title`: The dialog's title text. --- * `informative_text`: The dialog's main message text. --- * `text`: The dialog's initial input text. +-- * `informative_text`: The dialog's main message text. If the value is a +-- table, the first table value is the main message text and any subsequent +-- values are used as the labels for multiple entry boxes. Providing a +-- single label has no effect. +-- * `text`: The dialog's initial input text. If the value is a table, the +-- table values are used to populate the multiple entry boxes defined by +-- `informative_text`. -- * `button1`: The right-most button's label. The default value is -- `_L['_OK']`. -- * `button2`: The middle button's label. @@ -201,8 +216,13 @@ function secure_inputbox(options) end -- @param options Table of key-value option pairs for the input box. -- -- * `title`: The dialog's title text. --- * `informative_text`: The dialog's main message text. --- * `text`: The dialog's initial input text. +-- * `informative_text`: The dialog's main message text. If the value is a +-- table, the first table value is the main message text and any subsequent +-- values are used as the labels for multiple entry boxes. Providing a +-- single label has no effect. +-- * `text`: The dialog's initial input text. If the value is a table, the +-- table values are used to populate the multiple entry boxes defined by +-- `informative_text`. -- * `no_cancel`: Do not display the "Cancel" button. The default value is -- `false`. -- * `string_output`: Return the selected button's label or the dialog's exit diff --git a/core/ui.lua b/core/ui.lua index dd0fd522..fa2d5d51 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -105,9 +105,13 @@ ui.dialogs = setmetatable({}, {__index = function(t, k) local files = {} for file in result:gmatch('[^\n]+') do files[#files + 1] = file end return files - elseif k == 'filteredlist' then + elseif k == 'filteredlist' or + k:find('input') and result:match('^[^\n]+\n?(.*)$'):find('\n') then local button, value = result:match('^([^\n]+)\n?(.*)$') if not options.string_output then button = tonumber(button) end + if k:find('input') then + options.string_output, options.select_multiple = true, true + end local items = {} for item in value:gmatch('[^\n]+') do items[#items + 1] = options.string_output and item or tonumber(item) + 1 -- cgit v1.2.3