Skin functions on opening a window (1 Viewer)

Rob Hexenmeister

MP Donator
  • Premium Supporter
  • May 12, 2011
    207
    49
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    Morning all,

    I want to execute a skin function as soon as a window opens, and I think the easiest way might be to put it in the <onfocus> part of the control that gains focus when the window is opened.

    However, the window I want to do this on is videoFullScreen.xml, and while from the code it looks like control <id>13 takes focus, I am really not sure that it does. Does anybody have some insight into this, or can recommend a better way of executing a skin function on window open?

    Many thanks
    RH
     

    CyberSimian

    Test Group
  • Team MediaPortal
  • June 10, 2013
    2,849
    1,771
    Southampton
    Home Country
    United Kingdom United Kingdom
    from the code it looks like control <id>13 takes focus, I am really not sure that it does.
    The control that receives the focus on entry to a panel is defined by the <defaultcontrol> tag. You can specify any id that you want -- it does not have to be 13. In my skin I use the value 1616 in "VideoFullscreen.xml". 1616 is the id of a control that I use to control the visibility of other controls. I notice that although "DefaultWideHD" uses 13, there does not seem to be a control that has that id. I guess that if the specified control does not exist, the skin engine picks a control that does exist, using some algorithm of its own.

    I scanned my skin to see if I use <onfocus>, but in fact I don't use it anywhere. I have a recollection that I did try using it, but that it did not behave as I wanted in the circumstances in which I wanted to use it. But I cannot remember the details. However...

    "DefaultWideHD" uses <onfocus> many times. Look at the files with names beginning "BasicHomeEditor". Most occurrences are used with "skin.setstring()", so that certainly works, but whether other skin functions can be used with <onfocus> will have to be determined by trial and error.

    If you want to execute a skin function when a panel opens, you might be able to use the <define> tag at the start of the file (following <window> but before <controls>). The <define> tag is executed once when the panel opens. However, "VideoFullscreen.xml" might be a problem, since I think that logically the file is processed when video starts playing, even though there is nothing on the screen generated by the xml file. Again, trial and error will be needed to determine whether this would work. I have used the following functions in <define> tags:
    cint(), add(), sub(), mul(), div(), string.trim()

    -- from CyberSimian in the UK
     

    Rob Hexenmeister

    MP Donator
  • Premium Supporter
  • May 12, 2011
    207
    49
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    "DefaultWideHD" uses <onfocus> many times.

    Afternoon CyberSimian, hope you are well.

    Thank you, yes, I already use the <onfocus> method a lot already to good effect, especially with navigation, and like you, I use dummy controls.

    I am building my theme on DefaultWide. I have tried putting in a dummy control 13 at the start of the controls in the xml but I am not sure it does actually gain focus at all, which I think may be a specific behaviour of videoFullScreen.xml [unless control 13 is the actual full screen video and is hard coded ...in which case setting the default control to something else just might work]

    What I am aiming to do is set up a conditional navigation when the window opens. Something I have done many times before: eg:

    <onfocus>#(skin.setfocus(2005,#(switch.. ....etc)))</onfocus>

    I have used the following functions in <define> tags:
    cint(), add(), sub(), mul(), div(), string.trim()

    The part of your post I really do lack knowledge is the use of defines. I know how to set a basic skin variable in a define at the start of a xml thanks to excellent guidance from yourself, ajs and Catavolt in the past. What I don't really know is how to use functions in defines, especially #(skin.setfocus(xx,xx))

    Do you have an example you can point me to where you have used something like add() or string.trim() in a define for me to look at?

    Thank you, as ever
    RH
     

    CyberSimian

    Test Group
  • Team MediaPortal
  • June 10, 2013
    2,849
    1,771
    Southampton
    Home Country
    United Kingdom United Kingdom
    Do you have an example you can point me to where you have used something like add() or string.trim() in a define for me to look at?
    Here are a couple of examples from my skin:

    Code:
    <!-- height of TV and radio guides -->
    <define property="true" evaluateNow="true"
      >#cw.guide.h:#(
      div(add(mul(cint(#cw.guide.rows),3733),6319),100))</define>
    
    <!-- number of rows in a name list (use skin setting) -->
    <!-- note: value is stored as "#(n)", so need to remove "#()" -->
    <define property="true" evaluateNow="true"
      >#cw.nlist.rows:#(string.trim(#skin.list.rows,'()#'))</define>

    These examples are ones that return string values, with no side effects. I think that "skin.setfocus()" also returns a string value (the null string), but its primary purpose is the side effect of setting the focus. I don't know whether that would work in a <define>. :unsure:

    Here is a more-complex example from "DefaultWideHD":

    Code:
    <define property="true" evaluateNow="true"
      >#TV8:#(string.format('{0}{1}',#TV8.name,iif(eq(#TV8.active,' '),'',#PLUGERROR))
      )</define>

    When I want to understand how something is used, I first scan my own skin to see if I have already used it and forgotten, and then I scan DWHD to see if DWHD has used it. I use the Windows "findstr.exe" to search the skin files, and direct the output to a file to browse at my leisure. Example: to find occurrences of the <define> tag:

    Code:
    findstr.exe "<define" *.xml >findstr.out

    -- from CyberSimian in the UK
     

    Rob Hexenmeister

    MP Donator
  • Premium Supporter
  • May 12, 2011
    207
    49
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    use the Windows "findstr.exe" to search the skin files
    Many thanks for the above. It certainly gives me some ideas to try out. Probably not for a week or two though as I am back to work with a full diary tomorrow!

    Your tip on findstr.exe is a gamechanger. It should be at the top of the skinner's guide as a useful tip!

    Thank you
    RH
     

    Rob Hexenmeister

    MP Donator
  • Premium Supporter
  • May 12, 2011
    207
    49
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    If you want to execute a skin function when a panel opens, you might be able to use the <define> tag at the start of the file

    I can confirm this definitely does not work on fullscreen TV,

    "VideoFullscreen.xml" might be a problem, since I think that logically the file is processed when video starts playing

    Trying to set focus to anything other than control 13 on window open by any method doesn't work, and I believe the control must be hard-coded into MP

    This is a shame, and it is an example of MP being too rigidly coded. Having a full screen window fully coded into MP is not necessary when there is a video window control in MP that could have been been used with xpos 0, ypos 0, width 1280, height 720 instead. It reduces skinning flexibility, and it would be my suggestion for a possible future upgrade to MP that this is implemented as a change.

    eg:
    Fullscreen TV xml:

    <defines>etc
    <allowoverlay>no< etc.....

    <controls>
    <control>
    <id>13</id>
    <description>fullscreen video</description>
    <type>videowindow</type>
    <visible>control.hasfocus(13) + player.hasvideo</visible>
    <posX>0</posX>
    <posY>0</posY>
    <width>1280</width>
    <height>720</height>
    <action>106</action> [context menu but could change this]
    <textureFocus>-</textureFocus>
    <onup>21</onup>
    <ondown>40</ondown>
    <onleft>13</onleft>
    <onright>13</onright>
    </control>

    <----MENU AND VIDEO INFORMATION---->

    <control>
    <id>1</id>
    <type>label</type>
    <label>#TV.View.title</label>
    </control>


    <control>
    <type>group</type>
    <stacklayout> etc etc

    <control>
    <id>40></id>
    <type>menubutton</type>
    <hyperlink>600<hyperlink> (TV Guide)
    <onup>13</onup>
    <visible allowhiddenfocus="yes">!control.hasfocus(13)</visible>
    etc

    <control>
    <id>41></id>
    <type>menubutton</type>
    <action>10<action> (action previous menu but could be anything you want)
    <onup>13</onup>
    <visible>!control.hasfocus(13)</visible>
    etc



    Anyway, for me it's time to move on to modify other xmls....
     

    CyberSimian

    Test Group
  • Team MediaPortal
  • June 10, 2013
    2,849
    1,771
    Southampton
    Home Country
    United Kingdom United Kingdom
    Trying to set focus to anything other than control 13 on window open by any method doesn't work, and I believe the control must be hard-coded into MP
    The MP skin engine has many quirks and restrictions :(. Whenever I encounter some behaviour that is unexpected, I try to make a note in the xml file. Looking at "VideoFullscreen.xml", I see that I have this:

    Code:
    <!-- SACRIFICIAL CONTROL -->
    <control Style="CwController">
      <description>Sacrificial control.
        The first control in "VideoFullScreen.xml" is always ignored by the
        skin engine, so we provide this control so that it can be ignored.
      </description>
      <type>image</type>
      <posX>#cw.panel.offscreen.x</posX>
      <posY>#cw.panel.offscreen.y</posY>
      <visible>false</visible>
    </control>

    This is the first control following the <controls> tag. The same control is present in "MyTvFullscreen.xml". As far as I know, these are the only two xml files where the first control is always ignored.

    Perhaps you already have a sacrificial control at the start of those two xml files. But if you do not, maybe it is the reason why you have not been able to obtain the result that you want?

    -- from CyberSimian in the UK
     

    Users who are viewing this thread

    Top Bottom