jf-roku/components/config/ConfigList.brs

75 lines
1.6 KiB
Plaintext
Raw Normal View History

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
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
end sub
2019-05-03 12:48:59 +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
2021-07-09 20:08:32 +00:00
show_dialog(itemField)
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
sub show_dialog(configField)
dialog = createObject("roSGNode", "StandardKeyboardDialog")
2021-07-09 20:08:32 +00:00
m.configField = configField
dialog.title = "Enter the " + configField.label
dialog.buttons = [tr("OK"), tr("Cancel")]
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"
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
end sub