2016-08-23 35 views
0

我使用此代码进行验证。点击ok键盘后,roku设备重新启动。 我想让新键盘显示密码。roku设备停止工作,同时调用函数

子的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 

回答

0

我遇到尝试从另一个打开一个对话框同样的问题,我管理通过使用定时器来解决它。

在我的XML我添加

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

而且在第一个对话框点击

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

然后是功能showDialogTimer处理接下来的对话框

sub showDialogTimer() 
    showDialog() 
end sub