Kodi Community Forum

Full Version: Issue executing key presses through <onclick>
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys, previously in Dharma I added a sub-menu button to Neon to add a source that was rather crafty; for Videos, I would open up File View, hit the Up key a few times to roll back over and highlight "Add Source", then send the Select command to pull up the window.

However, in updating my skin to Eden I found that key presses are no longer functioning when I add them into the <onclick> parameter within my menu item, nothing happens. Here's my code that's not functioning:

Quote:<item id="0">
<description>add source test</description>
<label>test</label>
<icon>special://skin/backgrounds/custom.jpg</icon>
<onclick>ActivateWindow(videofiles,root)</onclick>
<onclick>Action(up)</onclick>
<onclick>up</onclick>
<onclick>select</onclick>
<visible>!Skin.HasSetting(HomeMenuNoMoviesButton) + Library.HasContent(Movies)</visible>
</item>

Furthermore, when looking into calling the Media Source dialog window directly, I can do so but it does not gain focus. Also attempting to set focus to the window through a similar <onclick> command does not work and I don't understand why.

Any input is massively appreciated.
ActivateWindow(video,files) will be the first step. That will get you to the "root" of files, assuming the user has actually added some sources. If no sources are there, it'll dump you to the root of the library instead.
My issue honestly does not lie within getting to file view of the video library, but that I cannot execute key presses through <onclick> as I could previously in Dharma. I'm growing weary that I can consistently add a source due to the fact that (at least in Neon) the "Add Videos..." option is not always at the bottom of the displayed list.

Which brings me to my secondary solution to the problem, which would certainly be consistent...I can currently call the media source dialog on screen through this code below, but I cannot shift focus to it without using my mouse. Here's my code:

Quote: <item id="0">
<description>add source test</description>
<label>test</label>
<icon>special://skin/backgrounds/custom.jpg</icon>
<onclick>ActivateWindow(10129)</onclick> <!-- Successfully opens dialog -->
<!--onclick>Control.SetFocus(10129,13)</onclick--> <!-- No change -->
<!--onclick>Control.SetFocus(10129)</onclick--> <!-- No change -->
<!--onclick>Control.SetFocus(129)</onclick--> <!-- No change -->
<!--onclick>Control.SetFocus(13)</onclick--> <!-- No change -->
<!--onclick>SetFocus(13)</onclick--> <!-- No change -->
<!--onclick>SetFocus(10129)</onclick--> <!-- No change -->
<!--onclick>SetFocus(129,13)</onclick--> <!-- No change -->
<!--onclick>SendClick(13)</onclick--> <!-- No change -->
<!--onclick>SendClick(129,13)</onclick--> <!-- No change -->
<!--onclick>SendClick(10129,13)</onclick--> <!-- No change -->
<visible>true</visible>
</item>

Now like I mentioned, the dialog is brought up successfully but is not in focus and does not respond to key presses either via keyboard or remote. However, if I use a mouse and move my cursor over any of the buttons within the dialog, I can click on them and successfully add and subsequently scrape sources. Through code, how can I achieve this? Reading through the wiki, I landed on SendClick and SetFocus, but none of my actions seem to shift attention to the dialog. Where am I going wrong?

To be clear, in the code 10129/129 is the Window ID for DialogMediaSource, and 13 is the button ID for the Add button within the Media Source dialog.
You'll need to edit <defaultcontrol always="true">10</defaultcontrol> in DialogMediaSource.xml to the button you want to get focus. The list (id=10) can't get focus if there's no content (which there wont be if you're opening from elsewhere in the skin).
Hitcher that worked great, thanks! I shifted default focus to the Add button of the media source dialog so I can now add sources from my home screen...at least for Videos. When I attempt to add an audio source, it brings up the Set Content window which does not allow me to scrape for music and the newly added source is not added properly. Even bringing up the Music window before calling the Media Source dialog does not allow me to add the audio source.

Again, thanks for the input and assistance, I greatly appreciate everything you guys do.
This is completely not supported. That it worked is quite frankly completely unintentional. The dialog needs to know it's context, and it gets told it's context from the window that calls it. You cannot replicate this from the skin.
jmarshall Wrote:This is completely not supported. That it worked is quite frankly completely unintentional. The dialog needs to know it's context, and it gets told it's context from the window that calls it. You cannot replicate this from the skin.

That's unfortunate. I managed to code in a shortcut for my music sub-menu to basically perform the key presses for me to navigate to file view and hit Add Source, so my initial reason for posting is done.

Going forward beyond Eden, do you foresee yourself and the dev team adding in ability for the skin to perhaps pass contextual information to called dialogs? I know it's a bit much to ask for, especially if it would only affect a handful of things, but being able to quickly add a source from my home screen is a massive help not for myself but for the inexperienced and rather non-technical users in my household.
Perhaps I'm missing something. How does it make things easier to be able to add a source from the home screen?
jmarshall Wrote:How does it make things easier to be able to add a source from the home screen?

For a first time user that's not familiar with XBMC, adding their media to a library is not intuitive. Having a self-explanatory button on the home screen that says "Add source" or "Add your movies" trims down on the learning curve significantly for average and even non-technical users.

I understand it's not something that will necessarily get daily use, especially if the media you're viewing with XBMC is stored in a coherent and easily digestible format. However, take into consideration someone that's installed a HTPC running XBMC in a home theater for a non-technical user; it's easier to support the product if important tasks such as adding a source or updating a library are at the fingertips of the user and easily accessible through a submenu.

If I'm way off base, I understand but that's my opinion as a PC support guy. I'm just trying to make life potentially easier for people supporting XBMC installs for low-tech users.
Right, but the button is basically useless after that initial addition, right? The future will hopefully see setup of sources done through settings (and callable from elsewhere, ofcourse) thus allowing first time "setup your sources" type stuff.