Correct way to set focus to media container with viewmodes
#1
This has been bugging me for a while.  In windows with media containers how best to get focus back to the container regardless of what the current viewmode is set to?   Does it matter how you declare your <views>?  The last focused listitem in the container is OK.

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply
#2
Doesn't using 50 work as that's the default and Kodi should then focus on the only visible one?
Reply
#3
(2021-04-29, 09:42)Hitcher Wrote: Doesn't using 50 work as that's the default and Kodi should then focus on the only visible one?
I thought maybe that was the way, but couldn't find any documentation for it.  Mostly I am using a  SetFocus() in an onclick or ondown.  ISTR at one time views had to be in the range 50 -- 59 but now I think they can be anything?  Also it wasn't clear to me if you had to actually have a view with id 50.

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply
#4
(2021-04-29, 04:07)scott967 Wrote: This has been bugging me for a while.  In windows with media containers how best to get focus back to the container regardless of what the current viewmode is set to?   Does it matter how you declare your <views>?  The last focused listitem in the container is OK.
Not sure if I understand you correctly but have you tried something like this ?

MyVideoNav.xml (e.g. with id 800):

<defaultcontrol always="true">800</defaultcontrol> <!-- Set this to your first/main viewmode id -->
<views>800,801,802,803</views>

Now "SetFocus(800)" will always focus your viewmode container regardless of what viewmode is active.
Reply
#5
I confirm bkurys statememt about the importance of the
defaultcontrol.

also unsure if that helped and if that is the right track to looking for in source code.

xbmc/view/ViewDatabase.h

xbmc/view/GUIViewControl.h

xbmc/view/GUIViewControl.cpp
Skins |  Titan M O D   •   S W A N (WIP)
Reply
#6
I will try to dig around in the code some (not that I can figure it out though).  I see the use of the default control to the first listed view in the window's <views> used in skins.  That seems like a logical approach.  But I'm also not knowledgeable about how control id's get managed in a window's (and any dialog's) context.

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply
#7
Have done some work on this.  The "view" seems to use a combination of the "viewtype" and control IDs set in <views>.  These are stored in the db as a 32 bit integer with the high order word the viewtype (x0001-x000a) and the low order word the control id (don't see any limitation on valid view IDs other than obviously <= xffff).  But exactly how (or if) the viewtype is actually used and don't see.  I don't think there is any way for a skin or addon to request a viewtype.   I could see maybe an addon could if it wasn't supplying its own xml window.

I see where the valid view IDs are getting read from the xml and stored at runtime, and used when the previous or next view builtin is sent.  But I still don't see how the SetFocus message is processed for views.  It's kind of complex since  SetFocus could be used to focus a specific container listitem in addition to focusing the container itself (with implied listitem focus).

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply
#8
It used to be the case that views can only use IDs 50-55 and for any more they had to be higher because there could be other controls with the same ID.
Reply
#9
(2021-05-05, 03:10)scott967 Wrote: But I still don't see how the SetFocus message is processed for views.  It's kind of complex since  SetFocus could be used to focus a specific container listitem in addition to focusing the container itself (with implied listitem focus).

scott s.
.

yepp, and that's unfunny was confusing me too.

But i am pretty unfamiliar with python to lookup for the correct source in xbmc/
(so maybe thats leading in wrong direction but a try is looking here  https://github.com/xbmc/xbmc/blob/master...Window.cpp )
code:


CGUIWindow::CGUIWindow(int id, const std:Confusedtring &xmlFile)
{
CGUIWindow::SetID(id);
SetProperty("xmlfile", xmlFile);
m_lastControlID = 0;
m_needsScaling = true;
m_windowLoaded = false;
m_loadType = LOAD_EVERY_TIME;
m_closing = false;
m_active = false;
m_renderOrder = RENDER_ORDER_WINDOW;
m_dynamicResourceAlloc = true;
m_previousWindow = WINDOW_INVALID;
m_animationsEnabled = true;
m_manualRunActions = false;
m_exclusiveMouseControl = 0;
m_clearBackground = 0xff000000; // opaque black -> always clear
m_windowXMLRootElement = nullptr;
m_menuControlID = 0;
m_menuLastFocusedControlID = 0;
m_custom = false;
}
...

bool CGUIWindow::OnAction(const CAction &action)
{
  if (action.IsMouse() || action.IsGesture())
    return EVENT_RESULT_UNHANDLED != OnMouseAction(action);

  CGUIControl *focusedControl = GetFocusedControl();
  if (focusedControl)
  {
    if (focusedControl->OnAction(action))
      return true;
  }
  else
  {
    // no control has focus?
    // set focus to the default control then
    CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), m_defaultControl);
    OnMessage(msg);
  }
...
  }

Some weird input from my side.
( my human mind isnt in sync with the behaviour ,
i mean i tend to believe view type visible conditions hide the defined containers and belonging controls if exist, at specific conditions.
And an use action/builtin to focus the defaultcontrol if the visible condition for that control id is 'false' should'nt be possible )

But thats surely not the case which leads me to thinking
SetFocus(**viewtype id**) - will auto check first matching visible container id defined in view tag for that media window


looking for the built in SetFocus(id,pos) is not really necessary, as you can also simply use the id without a defined builtin cmd
e.g.

<onleft>50</onleft>
or/and
<onback>50</onback>


refering to https://kodi.wiki/view/Default_control_tags
text:

onup                 Specifies the <id> of the control that should be moved to when the user moves up off this control. Can point to a control group (which remembers previous focused items).
ondown             Specifies the <id> of the control that should be moved to when the user moves down off this control. Can point to a control group (which remembers previous focused items).
onleft                Specifies the <id> of the control that should be moved to when the user moves left off this control. Can point to a control group (which remembers previous focused items).
onright              Specifies the <id> of the control that should be moved to when the user moves right off this control. Can point to a control group (which remembers previous focused items).
onback              Specifies the <id> of the control that should be focussed when the user presses the back key. Can point to a control group (which remembers previous focused items).

    media window (e.g. videos , music , games)
    * select and onback actions are handled by kodi and can't be easily used with an override action (select,onback)
    * kodi check for content and belonging visible conditions based on viewtype id (e.g. content change,windowchange: **.db entry > defaultcontrol id / first visible view id)

   https://kodi.wiki/view/Window_Structure
text:


    <defaultcontrol>
        This specifies the default control of the window. This is the id of the control that will receive focus when the window is first opened. Note that most Kodi windows save the current focus when you leave the window, and will return to the last focused item when you return to a window. This behaviour can be stopped by specifying the attribute always="true".
    <views> tag
        This tag lets you use view id's beyond 50 to 59 it also lets you set the order in which they cycle with the change view button in the skin. Only useful in My<Foo>.xml windows.
Skins |  Titan M O D   •   S W A N (WIP)
Reply

Logout Mark Read Team Forum Stats Members Help
Correct way to set focus to media container with viewmodes0