Skin functions on opening a window (1 Viewer)

Rob Hexenmeister

MP Donator
  • Premium Supporter
  • May 12, 2011
    190
    42
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    Country flag
    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,346
    1,428
    Southampton
    Home Country
    United Kingdom United Kingdom
    Country flag
    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
    190
    42
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    Country flag
    "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,346
    1,428
    Southampton
    Home Country
    United Kingdom United Kingdom
    Country flag
    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
    190
    42
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    Country flag
    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
    190
    42
    Slaithwaite
    Home Country
    United Kingdom United Kingdom
    Country flag
    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,346
    1,428
    Southampton
    Home Country
    United Kingdom United Kingdom
    Country flag
    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

    Similar threads

    Very interesting! I was not aware of that plugin. Thanks for bringing it to my attention. :) I read your other thread about "Latest Media Handler", but I cannot offer any advice as it is not a plugin that I have used :(. Hopefully someone with more knowledge will be able to help. :) -- from CyberSimian in the UK
    Very interesting! I was not aware of that plugin. Thanks for bringing it to my attention. :) I read your other thread about...
    Good evening! I would like MediaPortal to start up on an alternative screen (TV Scheduler). I have tried two methods which I hoped...
    Replies
    3
    Views
    823
    Ok, just done some more mucking around. turns out my logitech mouse seems to be extremely unresponsive in media portal. Can use my keyboard just fine (also lightspeed wireless). Suggestions?
    Ok, just done some more mucking around. turns out my logitech mouse seems to be extremely unresponsive in media portal. Can use my...
    Good evening, having just fresh installed media portal 2.3.2. Looking at trialing again as it now seems to support what I am...
    Replies
    1
    Views
    145
    Agree totally with the first part of this, my intentions are to move the buttons that I don't like off of the screen where they can't be seen. What I was hoping to do was create two new buttons in the menubutton style, (dialoglist mode), and alter the relevant OnlineVideos properties. As one is only number of items to display, and...
    Agree totally with the first part of this, my intentions are to move the buttons that I don't like off of the screen where they...
    Good evening everyone, I need some help with skinning buttons for Online Videos. What I am trying to achieve is move the buttons...
    Replies
    2
    Views
    611
    Pre Releases are provided as a way for the community to test and give feedback on all the exciting things we have lined up for the next release. We allocate about one month for Pre Release testing. In that time we will only fix bugs, after which comes the final release! Highlights of this release Bugfixes: [MP1-5081] - WatchDog...
    Pre Releases are provided as a way for the community to test and give feedback on all the exciting things we have lined up for the...
    Pre Releases are provided as a way for the community to test and give feedback on all the exciting things we have lined up for the...
    Replies
    0
    Views
    444
    • Sticky
    We have just released MediaPortal 1.29 The Phantom Menace Highlights of this release Bugfixes: [MP1-5081] - WatchDog not switch Mediaportal log to Debug level [MP1-5082] - Error when MP restart [MP1-5086] - XMLTV Import error - An item with the same key has already been added. Since Pre-Release : [MP1-5089] - MpurlSourceSplitter...
    We have just released MediaPortal 1.29 The Phantom Menace Highlights of this release Bugfixes: [MP1-5081] - WatchDog not switch...
    We have just released MediaPortal 1.29 The Phantom Menace Highlights of this release Bugfixes: [MP1-5081] - WatchDog not switch...
    Replies
    0
    Views
    211
    Top Bottom