0

i used this code for validation .after click on ok of the keyboard the roku device gets reboot. I want new keyboard to be displayed for password .

sub init() m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"

  example = m.top.findNode("instructLabel")

  examplerect = example.boundingRect()
  centerx = (1280 - examplerect.width) / 2
  centery = (720 - examplerect.height) / 2
  example.translation = [ centerx, centery ]

  m.top.setFocus(true)
end sub

sub showdialog()
  keyboarddialog = createObject("roSGNode", "KeyboardDialog")
  keyboarddialog.backgroundUri = "pkg:/images/rsgde_dlg_bg_hd.9.png"
  keyboarddialog.title = "Example Keyboard Dialog"

  keyboarddialog.buttons=["OK","CANCEL"]
  keyboarddialog.optionsDialog=true

  m.top.dialog = keyboarddialog


KeyboardDialog.observeField("buttonSelected","onKeyPress")


end sub



 sub showpassword()
  keyboarddialog = createObject("roSGNode", "KeyboardDialog")
  keyboarddialog.backgroundUri = "pkg:/images/rsgde_dlg_bg_hd.9.png"
  keyboarddialog.title = "Example Keyboard Dialog"

  keyboarddialog.buttons=["OK","CANCEL"]
  keyboarddialog.optionsDialog=true

  m.top.dialog = keyboarddialog


end sub


function onKeyPress()
    check=CreateObject("roRegex", "^[A-Za-z0-9_%+-]+(\.[A-Za-z0-9_%+-]+)*@([A-Za-z0-9-]+\.)+[A-Za-z]{2,6}$", "i").IsMatch(m.top.dialog.text)

        if(check)
            showpassword()

    else
        print "invalid"
    end if
end Function




function onKeyEvent(key as String, press as Boolean) as Boolean
  if press then
    if key = "OK"
      showdialog()

      return true
    end if

    end if


  return false
end function

1 Answers1

0

I've encountered the same issue while trying to open one dialog from another, I managed to solve it by using a timer.

On my XML I've added

<Timer
      id="dialogTimer"
      repeat="false"
      duration="0.1"
/>

And on the first dialog click

m.top.dialog.close = true
m.dialogTimer = m.top.findNode("dialogTimer")
m.dialogTimer.control = "start"
m.dialogTimer.ObserveField("fire","showDialogTimer")

And then the function showDialogTimer handles the next dialog

sub showDialogTimer()
    showDialog()
end sub
Eladit
  • 168
  • 1
  • 2
  • 9