(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:tring &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.