OG_OTT
7 years agoVisitor
setFocus question
For the below code, I have two questions...
For this particular snippet it was part of a scene where I threw a bunch of components into the scene just to test them out... there is a button component for which I "select" when I press the down key. Originally, when I pressed any other key was setting m.button.setFocus(False).
I can paste more code, but I figured this is a pretty 'n00b' question.
For this particular snippet it was part of a scene where I threw a bunch of components into the scene just to test them out... there is a button component for which I "select" when I press the down key. Originally, when I pressed any other key was setting m.button.setFocus(False).
- Question 1: Why, when I set this to `false` did my focus just disappear into the scene and no additional key events could be captured?
- Question 2: I 'fixed' the problem by losing focus on the button, which didn't highlight it anymore, and then returning focus to m.top. Is this the correct "pattern" to use? It feels odd to me that I would have to explicitly lose focus on something before re-gaining the parent focus I once I had.
I can paste more code, but I figured this is a pretty 'n00b' question.
Function onKeyEvent(key as String, press as Boolean) as Boolean
handled = false
if press
if key = "down"
? "down was pressed"
m.button.setFocus(True)
handled = True
else
m.button.setFocus(False)
m.top.setFocus(True)
? "some other button was pressed"
handled = True
end if
end if
return handled
end Function