Button and setFocusId
#1
Hi,
I've just started to learn XBMC scripting and everything has been going smooth, so far.
But now I have encountered a problem I just can't seem to solve.

From the XML-file:
PHP Code:
<control type="button" id="3">
<
posx>180</posx>
<
posy>200</posy>
<
width>180</width>
<
texturefocus>Subtitles.png</texturefocus>
<
texturenofocus>mynormaltexture.png</texturenofocus>
<
label>Button1</label>
<
onfocus>-</onfocus>
</
control
And from the python script:
PHP Code:
ACTION_SELECT_ITEM 7

def onAction
(selfaction):
if(
action == ACTION_PREVIOUS_MENU or action == ACTION_PARENT_DIR):
     
self.close()
if(
action == ACTION_SELECT_ITEM):
     
self.SetFocusId(3

Why doesn't the button get focus? Maybe I have misunderstood something, but shouldn't the button show my chosen image when I hit <Enter>?
Reply
#2
If you want to use your button on <enter> you need to use the onControl
method instead of onAction.

It will look something like that in your case.
Code:
def onControl(self, control):
       if control == self.yourbutton:
           self.showImage()
Where control is the button being hit.

setFocus method is used for highlighting buttons and not clicking/hitting them.
Reply

Logout Mark Read Team Forum Stats Members Help
Button and setFocusId0