Kodi Community Forum

Full Version: defaultcontrol for xbmcgui.WindowDialog
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone, and please for helpSmile

I can't set default focus for windowDialog. After open my addon everything is right, but when i slide away mouse arrow from buttons then i can't focus any buttons by pressing arrow keys, only option is sliding mouse arrow back on button.

Code:
class PopupWindow(xbmcgui.WindowDialog):
  def __init__(self):
        #setting basic controls
    self.searchButton = xbmcgui.ControlButton(1100, 15, 160, 50, 'Search', font='Font40', alignment=0x00000006, noFocusTexture=xbmcaddon.Addon().getAddonInfo('path')+'/bottom_line.png',  focusTexture=xbmcaddon.Addon().getAddonInfo('path')+'/focus_bottom_line.png', focusedColor='0xFFAAAAAA')
    self.addControl(self.searchButton)
        #and rest of code
In my code is few more buttons which have set navigations between them.
Can Someone help me in that case?

And by the way, sorry for my english.
OK, I solved problem by myself

Code:
import xbmcgui

ACTION_PREVIOUS_MENU = 10

class PopupWindow(xbmcgui.WindowDialog):
  def __init__(self):
    ...
    ...
    ...
  def onAction(self, action):
    try:                                                        #this
      self.getFocus()                                   #is
    except:                                                 #what i
      self.setFocus(self.Button[0])             #needed
    if action.getButtonCode() == 61448 or action == ACTION_PREVIOUS_MENU:
      xbmc.executebuiltin('ReplaceWindow(Home)')
      self.close()

if __name__ == '__main__':
    window = PopupWindow()
    if xbmc.getCondVisibility('Window.IsActive(1100)'):
      window.doModal()
    window.close()
    del window