These functions are used to display dialogs for the user to interact with.
Synopsis: button, result_table = aegisub.dialog.display(dialog, buttons, button_ids)
This function displays a configuration dialog to the user and waits for it to close. It then returns whether the user accepted or cancelled the dialog, and what values were input.
@dialog
(table
)@buttons
(table
)@button_ids
(table
)button
(boolean
or string
)result_table
(table
)config = {
{class="label", text="Times to frobulate", x=0, y=0},
{class="intedit", name="times", value=20, x=0, y=1}
}
btn, result = aegisub.dialog.display(config,
{"Frobulate", "Nevermind"},
{"ok"="Frobulate", "cancel"="Nevermind"})
if btn then
frobulate(result.times)
end
Synopsis: file_name = aegisub.dialog.open(title, default_file, default_dir, wildcards, allow_multiple=false, must_exist=true)
Open a standard file open dialog to ask the user for a filename. Returns the path to the selected file(s), or nil if the user canceled.
@title
(string
)@default_file
(string
)@default_dir
(string
)@wildcards
(string
)@allow_multiple
(boolean
)@must_exist
(boolean
)file_name
(nil
, string
, or table
)nil
if the user cancelled. A string
containing the path to the
selected file if allow_multiple
is false, or a table containing the
paths to all selected files if allow_multiple
is true.filename = aegisub.dialog.open('Select file to read', '', '',
'Text files (.txt)|*.txt', false, true)
if not filename then aegisub.cancel() end
file = io.open(filename, 'rb')
....
Synopsis: file_name = aegisub.dialog.save(title, default_file, default_dir, wildcards, dont_prompt_for_overwrite=false)
Open a standard file save dialog to ask the user for a filename. Returns the path to the selected file, or nil if the user canceled.
@title
(string
)@default_file
(string
)@default_dir
(string
)@wildcards
(string
)@dont_prompt_for_overwrite
(boolean
)file_name
(nil
or string
)nil
if the user cancelled, and a string
containing the path to the
selected file otherwise.This section describes the tables passed to and received from
aegisub.dialog.display
and the export filter configuration
panel.
This file describes the functions and data structures used for the Configuration Dialog functionality in Automation 4.
A Dialog Control table describes a single control in a configuration dialog, which can display information to the user and allow them to change it.
There are a number of different classes of controls, and the keys a Dialog Control table must contain depends on the control class.
Common keys for all control classes:
class
(string
)Defines which class this control has. Must be one of:
x
(number
)y
(number
)width
(number
)height
(number
)x
,y
=0,0.
If any of width and height are set to zero or less, it will be set to one
instead.Keys defined for all classes except "label":
hint
(string
)name
(string
)Keys defined only for "label" and "checkbox" classes:
label
(string
)Key defined only for the "edit" and "textbox" classes:
text
(string
)Keys defined only for the "intedit" and "floatedit" classes:
value
(number
)min
(number or nil
)max
(number or nil
)min
and max
.Key defined only for the "floatedit" class:
step
(number or nil
)min
and max
are set (but
the values accepted will still be limited). Note that this does not
require that min
and max
be set.Keys defined only for the "dropdown" class:
items
(table
)value
(string
)Key defined only for the "checkbox" class:
value
(boolean
)Keys defined only for the "color", "coloralpha" and "alpha" classes:
value
(string
)The Dialog Definition table is simply an array of Dialog Control tables.
Note, however, that while the visual ordering of the controls are decided entirely by the "x", "y", "width" and "height" of the controls, the "tab order" of the controls is decided by their ordering in the Dialog Definition table. Your users will thank you if you make these match up.
A Dialog Result table contains the user input from a configuration dialog.
The control "name
" properties are used as keys in this table.
The type of the value for each entry in the table depends on the class of the control. The control classes map to types in the following manner:
label
: nil
edit
, textbox
: string
textbox
class control.intedit
, floatedit
: number
dropdown
: string
checkbox
: boolean
color
, coloralpha
, alpha
: string
value
property.Dialog result tables are purely output from the dialog. Changing them and then redisplaying the dialog will not have any effect.
Legal values for button IDs are: ok yes save apply close no cancel help context_help
Note that many combinations of button IDs do not make sense and may have
strange effects. For example, having both cancel
and close
buttons is a bad
idea.
Buttons with an ID of cancel
return false, as if ESC was pressed. A
button with an ID of close
results in that button being triggered on
ESC rather than cancel.
Buttons with an ID of ok
, yes
and save
are set as the default
affirmative button for the dialog.
Buttons with the ID help
will be displayed as a question mark in a circle on
the left side of the dialog on OS X.
Overview: | Automation Manager • Running macros • Using export filters • Standard macros |
---|---|
Karaoke Templater reference: | Declaring
templates • Execution
order • Modifiers • Inline-variables ($-variables)
Code lines and blocks • Execution envirionment |
Lua API reference: | Registration • Subtitles object • Progress reporting • Dialogs • Misc. APIs |
Lua Modules: | karaskel.lua • util • unicode • cleantags.lua • clipboard • re |
Karaskel concepts: | Style tables • Dialogue line tables • Syllable tables • Inline effects • Furigana |