Kodi Community Forum

Full Version: Weird focus/unfocus behavior on DialogVideoInfo.xml
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all,

I have noticed some weird behavior of <onfocus> and <onunfocus> on DialogVideoInfo.xml.
My code looks like:

<defaultcontrol always="true">9010</defaultcontrol>
    <control type="button" id="9010">

When I go into DialogVideoInfo for first time everything is correct, CurrentView is 9010 and PreviousView is empty. But when I leave dialog (onunload should care about cleanup) and open it again i get 9010 in both properties. To me it looks like dialog remember last focused item and unfocuses it after init. When I leave dialog with different button (with similar code) focused I get different number in PreviousView property, so it back ups my guess.

To me it doesn't seem like correct behavior. Should I create ticket for it?
You need to specify the window if you clear the properties in onunload:

PHP Code:

My guess is that it tries to clear the property in the previous window because that is already active when onunload is executed but I never investigated it further.
I tried to move my properties to home but it doesn't help. I think properties clearing on onunload works fine even on local window, i checked it with different use-case.
IMHO this problem isn't related to properties. I added


on button which isn't default control and when I leave dialog with that button focused I get no notification. But when I go to dialog again I immediately get notification.
How to test it on Confluence:
  • In DialogVideoInfo.xml update button with id="5" (lines 957-961) like

    <control type="button" id="5">
  • Go into DialogVideoInfo.xml and focus Cast button.
  • Leave dialog. Nothing happens, no notification.
  • Go into DialogVideoInfo.xml again. Notification immediately appears even when Browse button is focused by default.
That seems reasonable to me - after all, the control has lost focus, right?
I don't think so.
Of course control lost focus but in meantime it was (together with dialog) deinited and inited again for different list item/data.
I would more expect unfocus to be called before dialog deinit than after new initialization.
Only theory (not at computer with XBMC now):

Is this problem somehow related to feature that XBMC remeber last position in Window (not sure if it applies to dialogs too)? From outside point of view it looks like DialogVideoInfo first focus last used control and then defocus and focus defined default control. If that's case then it should IMHO ignore that remembered control on windows where is defined default control. Otherwise it makes onfocus/onunfocus usage quite complicated because it may have unexpected side effects during dialog start. Of course with my limited skinning experience I'm not able to consider all consequences.