Hi,
I give on the forum my script for manage tabindex, it's working well for me
function initTabIndex()
m._tabIndex = []
end function
function addTabIndex(id,targets)
m._tabIndex.push({id:id,targets:targets})
end function
function updateTabIndex(key)
currentIndex = _getFocusIndex()
currentItem = m._tabIndex[currentIndex]
if(currentItem = invalid) then return false
if(currentItem.targets.DoesExist(key)) then
target = currentItem.targets.Lookup(key)
m.top.findNode(target).setFocus(true)
return true
end if
return false
end function
function _getFocusIndex()
for i=0 to m._tabIndex.count()-1
item = m._tabIndex[i]
node = m.top.findNode(item.id)
if(node.focusedChild <> invalid) then
return i
end if
end for
return invalid
end function
How to use ?
Import the script in your xml
<script type="text/brightscript" uri="pkg:/components/util/UIUtil.brs" />
In your init() you can do something like that :
initTabIndex()
addTabIndex("keyboard",{down:"btnValidate"})
addTabIndex("btnValidate",{up:"keyboard",right:"btnShowPass"})
addTabIndex("btnShowPass",{left:"btnValidate",up:"keyboard",down:"btnOption"})
addTabIndex("btnOption",{left:"btnValidate",up:"btnShowPass"})
in your onKeyEvent :
function onKeyEvent(key as String, press as Boolean) as Boolean
if press then return updateTabIndex(key)
end function
in this sample, when you have the focus on btnShowPass, when you press left, you swap the focus to btnValidate
Best regards,
Jeremie.