2023-10-03 16:11:25 +00:00
|
|
|
import "pkg:/source/utils/config.bs"
|
2023-05-03 21:21:04 +00:00
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
sub init()
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.itemComponentName = "ConfigItem"
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.drawFocusFeedback = True
|
|
|
|
m.top.vertFocusAnimationStyle = "floatingFocus"
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.observeField("itemSelected", "onItemSelected")
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.itemSize = [750, 75]
|
|
|
|
m.top.itemSpacing = [0, 25]
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.setfocus(true)
|
2019-05-03 12:48:59 +00:00
|
|
|
|
|
|
|
end sub
|
|
|
|
|
2021-06-26 10:18:09 +00:00
|
|
|
sub setData()
|
2021-07-09 20:08:32 +00:00
|
|
|
items = m.top.configItems
|
|
|
|
data = CreateObject("roSGNode", "ContentNode")
|
|
|
|
data.appendChildren(items)
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.content = data
|
2021-06-26 10:18:09 +00:00
|
|
|
end sub
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-06-26 10:18:09 +00:00
|
|
|
sub onItemSelected()
|
2021-07-09 20:08:32 +00:00
|
|
|
i = m.top.itemSelected
|
|
|
|
itemField = m.top.content.getchild(i)
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2023-10-22 22:37:37 +00:00
|
|
|
configListShowDialog(itemField)
|
2021-06-26 10:18:09 +00:00
|
|
|
end sub
|
2019-05-03 12:48:59 +00:00
|
|
|
|
|
|
|
function onDialogButton()
|
2021-07-09 20:08:32 +00:00
|
|
|
d = m.dialog
|
|
|
|
button_text = d.buttons[d.buttonSelected]
|
|
|
|
|
|
|
|
if button_text = tr("OK")
|
|
|
|
m.configField.value = d.text
|
|
|
|
dismiss_dialog()
|
|
|
|
return true
|
|
|
|
else if button_text = tr("Cancel")
|
|
|
|
dismiss_dialog()
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
return false
|
2019-05-03 12:48:59 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
|
2023-10-22 22:37:37 +00:00
|
|
|
sub configListShowDialog(configField)
|
2022-09-05 06:50:13 +00:00
|
|
|
dialog = createObject("roSGNode", "StandardKeyboardDialog")
|
2021-07-09 20:08:32 +00:00
|
|
|
m.configField = configField
|
2022-09-08 19:19:48 +00:00
|
|
|
dialog.title = configField.label
|
2021-07-09 20:08:32 +00:00
|
|
|
dialog.buttons = [tr("OK"), tr("Cancel")]
|
2022-09-05 06:50:13 +00:00
|
|
|
m.greenPalette = createObject("roSGNode", "RSGPalette")
|
|
|
|
m.greenPalette.colors = {
|
|
|
|
DialogBackgroundColor: "#2A2B2A"
|
|
|
|
}
|
|
|
|
dialog.palette = m.greenPalette
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
if configField.type = "password"
|
2022-09-05 06:50:13 +00:00
|
|
|
dialog.textEditBox.secureMode = true
|
2021-07-09 20:08:32 +00:00
|
|
|
end if
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
if configField.value <> ""
|
|
|
|
dialog.text = configField.value
|
|
|
|
end if
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.getscene().dialog = dialog
|
|
|
|
m.dialog = dialog
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
dialog.observeField("buttonSelected", "onDialogButton")
|
2019-05-03 12:48:59 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
sub dismiss_dialog()
|
2021-07-09 20:08:32 +00:00
|
|
|
m.dialog.close = true
|
2020-01-04 21:37:06 +00:00
|
|
|
end sub
|