return a reference to the created dialogs

develop
myk002 2022-04-27 11:51:46 -07:00
parent dc2a14c0c2
commit 6ad362d698
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 18 additions and 9 deletions

@ -90,6 +90,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- ``widgets.ToggleHotkeyLabel``: new ``CycleHotkeyLabel`` subclass that toggles between ``On`` and ``Off`` states - ``widgets.ToggleHotkeyLabel``: new ``CycleHotkeyLabel`` subclass that toggles between ``On`` and ``Off`` states
- ``safe_index`` now properly handles lua sparse tables that are indexed by numbers - ``safe_index`` now properly handles lua sparse tables that are indexed by numbers
- ``widgets``: unset values in ``frame_inset``-table default to ``0`` - ``widgets``: unset values in ``frame_inset``-table default to ``0``
- ``dialogs``: ``show*`` functions now return a reference to the created dialog
# 0.47.05-r4 # 0.47.05-r4

@ -69,22 +69,26 @@ function MessageBox:onInput(keys)
end end
function showMessage(title, text, tcolor, on_close) function showMessage(title, text, tcolor, on_close)
MessageBox{ local mb = MessageBox{
frame_title = title, frame_title = title,
text = text, text = text,
text_pen = tcolor, text_pen = tcolor,
on_close = on_close on_close = on_close
}:show() }
mb:show()
return mb
end end
function showYesNoPrompt(title, text, tcolor, on_accept, on_cancel) function showYesNoPrompt(title, text, tcolor, on_accept, on_cancel)
MessageBox{ local mb = MessageBox{
frame_title = title, frame_title = title,
text = text, text = text,
text_pen = tcolor, text_pen = tcolor,
on_accept = on_accept, on_accept = on_accept,
on_cancel = on_cancel, on_cancel = on_cancel,
}:show() }
mb:show()
return mb
end end
InputBox = defclass(InputBox, MessageBox) InputBox = defclass(InputBox, MessageBox)
@ -133,7 +137,7 @@ function InputBox:onInput(keys)
end end
function showInputPrompt(title, text, tcolor, input, on_input, on_cancel, min_width) function showInputPrompt(title, text, tcolor, input, on_input, on_cancel, min_width)
InputBox{ local ib = InputBox{
frame_title = title, frame_title = title,
text = text, text = text,
text_pen = tcolor, text_pen = tcolor,
@ -141,7 +145,9 @@ function showInputPrompt(title, text, tcolor, input, on_input, on_cancel, min_wi
on_input = on_input, on_input = on_input,
on_cancel = on_cancel, on_cancel = on_cancel,
frame_width = min_width, frame_width = min_width,
}:show() }
ib:show()
return ib
end end
ListBox = defclass(ListBox, MessageBox) ListBox = defclass(ListBox, MessageBox)
@ -201,7 +207,7 @@ function ListBox:init(info)
on_submit2 = on_submit2, on_submit2 = on_submit2,
frame = { l = 0, r = 0}, frame = { l = 0, r = 0},
frame_inset = self.list_frame_inset, frame_inset = self.list_frame_inset,
row_height = info.row_height, row_height = self.row_height,
} }
} }
end end
@ -232,7 +238,7 @@ function ListBox:onInput(keys)
end end
function showListPrompt(title, text, tcolor, choices, on_select, on_cancel, min_width, filter) function showListPrompt(title, text, tcolor, choices, on_select, on_cancel, min_width, filter)
ListBox{ local lb = ListBox{
frame_title = title, frame_title = title,
text = text, text = text,
text_pen = tcolor, text_pen = tcolor,
@ -241,7 +247,9 @@ function showListPrompt(title, text, tcolor, choices, on_select, on_cancel, min_
on_cancel = on_cancel, on_cancel = on_cancel,
frame_width = min_width, frame_width = min_width,
with_filter = filter, with_filter = filter,
}:show() }
lb:show()
return lb
end end
return _ENV return _ENV