chaklasiyanikun
5 years agoRoku Guru
Is there any way to set by default key focus inside init() or inside XML component
My Button is below. I tried to focusBitmapUri set in XML and also set in init(). I need to button the focus image when the application launch. So, I set this field in init(). I tried focusable = "true". But no luck.
My XML File :
<Button id="Button" iconUri="" focusedIconUri="" showFocusFootprint="true"
focusFootprintBitmapUri="pkg:/images/button.png" minWidth="150" focusable="true"
height="50" translation="[440,500]" />
My brs File :
sub init()
     m.Button = m.top.findNode("Button") 
     ?m.Button.hasFocus()
     m.Button.focusBitmapUri = "pkg:/images/newsignin.png"
     m.Button.iconUri = ""
     m.Button.focusedTextColor = "0x00000000"
     m.Button.setFocus(true)
     ?m.Button.hasFocus()
     ?"m.Button.focusFootprintBitmapUri : "m.Button.focusFootprintBitmapUri
     ?"m.Button.focusBitmapUri : " m.Mac_Login.focusBitmapUri
     m.top.SetFocus(true)
end subIt's Completely Working fine. After, I set this field in onkeyEvent. In Documentation said this field worked after key focus. But, Is there any way to set by default key focus to this button when the application launches and init().
function onKeyEvent(key as String, press as Boolean) as Boolean
     result = false
     if key = "OK" then
          m.Button.focusBitmapUri = "pkg:/images/Button.png"
          m.Button.iconUri = ""
          m.Button.focusedTextColor = "0x00000000"
          m.Button.setFocus(true)
          ?m.Button.hasFocus()
          ?"m.Button.focusFootprintBitmapUri : "m.Button.focusFootprintBitmapUri
          ?"m.Button.focusBitmapUri : " m.Button.focusBitmapUri
         result = true
     end if
     return result 
end function