xoceunder
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2021
04:23 PM
I am trying to make a login work but it does not write me the password
RegScreen.brs
sub init() m.buttons = m.top.findNode("Buttons") m.code = m.top.findNode("Code") m.codeTimer = m.top.findNode("codeTimer") m.expireTimer = m.top.findNode("expireTimer") m.dialog = m.top.findNode("expireDialog") m.codeBox = m.top.findNode("codeBox") m.login = m.top.findNode("loginBox") m.keyboard = m.top.findNode("KeyboardText") m.label = m.top.findNode("enter") m.top.success = false ' create buttons result = [] for each button in ["Get new code","Log in with username and password"] result.push({title : button}) end for m.buttons.content = ContentList2SimpleNode(result) m.buttons.setFocus(true) m.code.font.size = m.code.font.size+5 m.code.text = "Retrieving..." m.getCode = createObject("roSGNode", "GetCode") m.validateCode = createObject("roSGNode", "ValidateCode") m.validateLogin = createObject("roSGNode", "LoginTask") m.getCode.observeField("state", "showCode") m.validateCode.observeField("validated", "validateSuccess") m.validateLogin.observeField("state", "validateLoginDone") m.codeTimer.observeField("fire", "validateCode") m.codeTimer.control = "start" m.expireTimer.observeField("fire", "expired") m.dialog.observeField("buttonSelected", "closeDialog") getNewCode() end sub sub getNewCode() m.expireTimer.control = "stop" m.getCode.control = "RUN" end sub sub expired() 'print "Code expired" m.dialog.visible = true m.dialog.setFocus(true) m.codeTimer.control = "stop" m.expireTimer.control = "stop" end sub sub closeDialog() 'print "Closing dialog" m.dialog.visible = false m.buttons.setFocus(true) if m.login.visible = false getNewCode() m.codeTimer.control = "start" m.expireTimer.control = "start" end if end sub sub showCode() if m.getCode.state = "stop" then if m.getCode.result then m.code.text = m.getCode.code m.expireTimer.duration = m.getCode.expires 'uncomment to add expiration to the activation code 'm.expireTimer.control = "start" else m.code.text = "Failed to get code..." end if end if end sub sub validateCode() 'print "in ValidateCode" if m.getCode.code <> "" then 'print "Code: "; m.getCode.code m.validateCode.validate = m.getCode.code m.validateCode.control = "RUN" end if end sub sub validateSuccess() 'print "in validateSuccess" m.expireTimer.control = "stop" m.codeTimer.control = "stop" if m.validateCode.validated or m.validateLogin.validated then m.top.success = true end sub sub validateLoginDone() 'print "in validateLoginDone" if m.validateLogin.state = "stop" then if m.validateLogin.validated then m.busyDialog.close = true validateSuccess() else dialog = createObject("roSGNode", "Dialog") dialog.title = "Login" dialog.buttons = ["Ok"] dialog.optionsDialog = true dialog.message = "Incorrect username or password" m.top.getScene().dialog = dialog end if end if end sub ' on Button press handler Sub onItemSelected() 'print "RegScreen.brs - [onItemSelected]" if m.codeBox.visible then if m.top.itemSelected = 0 'Get new code m.getCode.control = "RUN" else ' Login m.codeBox.visible = false m.label.text = "Enter username:" m.login.visible = true m.keyboard.setFocus(true) m.buttons.jumpToItem = 0 m.buttons.content.getChild(0).title = "Next" m.buttons.content.getChild(1).title = "Back" m.codeTimer.control = "stop" end if else if m.top.itemSelected = 0 if m.keyboard.text = "" then dialog = createObject("roSGNode", "Dialog") dialog.title = "Cannot leave field empty" dialog.optionsDialog = true dialog.buttons = ["Ok"] message = "Please enter a username" if m.keyboard.textEditBox.secureMode then message = "Please enter a password" dialog.message = message m.top.getScene().dialog = dialog else if not m.keyboard.textEditBox.secureMode m.keyboard.textEditBox.secureMode = true m.label.text = "Enter password:" m.top.user = m.keyboard.text m.keyboard.text = "" else m.top.validate = true m.keyboard.textEditBox.secureMode = false m.label.text = "Enter username:" m.top.pass = m.keyboard.text m.keyboard.text = "" end if else ' Go back m.keyboard.text = "" m.keyboard.textEditBox.secureMode = false m.label.text = "Enter username:" m.buttons.content.getChild(0).title = "Get new code" m.buttons.content.getChild(1).title = "Log in with username and password" m.codeTimer.control = "start" m.login.visible = false m.codeBox.visible = true end if end if End Sub sub validateLogin() 'print "In ValidateLogin()" if m.top.validate then m.top.validate = false 'print m.top.user 'print m.top.pass m.validateLogin.user = m.top.user m.validateLogin.pass = m.top.pass m.validateLogin.control = "RUN" m.busyDialog = createObject("roSGNode", "ProgressDialog") m.top.getScene().dialog = m.busyDialog end if end sub function onKeyEvent(key as String, press as Boolean) as Boolean result = false 'print "In RegScreen.brs onKeyEvent. Key pressed: ";key;" - Press: "; press if press then if key = "up" if m.login.visible = true and m.buttons.hasFocus() then m.keyboard.setFocus(true) result = true end if else if key = "down" if m.login.visible = true and not m.buttons.hasFocus() then m.buttons.setFocus(true) result = true end if end if end if 'print "Handled event: "; result return result end function '///////////////////////////////////////////' ' Helper function convert AA to Node Function ContentList2SimpleNode(contentList as Object, nodeType = "ContentNode" as String) as Object ''print "RegScreen.brs - [ContentList2SimpleNode]" result = createObject("roSGNode", nodeType) if result <> invalid for each itemAA in contentList item = createObject("roSGNode", nodeType) item.setFields(itemAA) result.appendChild(item) end for end if return result End Function
RegScreen.xml
<?xml version="1.0" encoding="UTF-8"?> <component name="RegScreen" extends="Group" initialFocus="Buttons" > <script type="text/brightscript" uri="pkg:/components/RegScreen/RegScreen.brs"/> <children> <!-- Control buttons (Button List) --> <LabelList id="Buttons" translation="[1040,900]" color="0xFFFFFFFF" focusedColor="0x333333FF" numRows="7" vertFocusAnimationStyle="floatingFocus" itemSpacing="[0,20]" itemSize="[700, 35]" textHorizAlign="right" /> <Rectangle id="codeBox" width="1300" height="400" color="0x101010C0" translation="[315,350]"> <Label id="Header" text="Activation Code" font="font:LargeBoldSystemFont" translation="[450,50]" horizAlign="center" width="400" /> <Label id="Code" font="font:LargeBoldSystemFont" translation="[450,150]" horizAlign="center" width="400" /> <Label id="explanation" text="Before using this channel, the channel must activate your account. Remain on this screen while logging in with this activation code." font="font:MediumBoldSystemFont" translation="[36,250]" numLines="3" wrap="true" width="1200" /> </Rectangle> <Rectangle id="loginBox" width="1410" height="500" color="0x101010C0" translation="[255,300]" visible="false"> <Label id="enter" translation="[30,10]"/> <Keyboard id="KeyboardText" translation="[0,60]"/> </Rectangle> <Timer id = "codeTimer" repeat = "true" duration = "5" /> <Timer id="expireTimer" repeat="true" duration = "900"/> <Dialog id="expireDialog" title="Code Expired" message="This code has expired. Press OK to get a new one" visible="false"/> </children> <interface> <!-- Button press handler --> <field id="itemSelected" type="integer" alwaysnotify="true" alias="Buttons.itemSelected" onChange="onItemSelected" /> <field id="user" type="string"/> <field id="pass" type="string"/> <field id="validate" type="boolean" alwaysNotify="true" onChange="validateLogin"/> <field id="success" type="boolean"/> </interface> </component>
1 Solution
Accepted Solutions
xoceunder
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021
07:00 AM
helps to be able to solve that you do not get what you type in keyboard
1 REPLY 1
xoceunder
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021
07:00 AM
helps to be able to solve that you do not get what you type in keyboard