Addressing (Panel) Items on the Home Window
#1
Hi all,
i have coded an extra window that gets initialized with:

Code:
def myWindow():
    dialog = MyWindow('myWindow.xml', ADDON_PATH, 'default', '720p')
    dialog.doModal()
    del dialog

That works great, within this new Window i can use "def onClick(self,controlId):" and "def onAction(self,action):" and the like to "capture" user inputs.

Now my question, is that also possible for the Home Window ID 10000?
I've already managed to have a Panel with ID 27400 in the Home Window, i can add Items to it with:
Code:
xbmcgui.Window(10000).getControl(27400).addItems(items)

(Where items is a list of ListItems...)

But for these items in that Panel, how do i "capture" it when i click/focus them, just like i do with "onClick(self,controlId)" in an extra window?
In other words: How do i use functions like onClick that i can use in extra windows in _already existing_ windows like Window 10000(Home)?

If anyone could hint me to an examlpe plugin where this is done or something, it would great - i am sure its possible Wink Thank YOU!
Reply
#2
Sorry, i think i found the solution (or at least right direction) myself: I have to use the monitor "xbmc.Monitor()" and within the "onNotification" function?

If anyone could tell me if this is the right direction or has an example addon doing this it would be great Wink
Reply
#3
(2024-08-30, 16:23)iceman20k Wrote: Sorry, i think i found the solution (or at least right direction) myself: I have to use the monitor "xbmc.Monitor()" and within the "onNotification" function?

If anyone could tell me if this is the right direction or has an example addon doing this it would be great Wink
I looked into this once and I think it isn't possible to capture much useful in windows you unless you have created them. Unfortunatley I think "onNotification" only captures the actual notifcations that Kodi receives (https://xbmc.github.io/docs.kodi.tv/mast...7a8a9a8dc7). 

I believe the general approach with xbmc.Monitor() is to create a poller that runs every x seconds. Mine I do 0.2 seconds. it's good enough for most things but it's not instantaneous. You can see mine here which was based on bits of @jurialmunkey and "@sualfred" addons: https://github.com/realcopacetic/script....tor.py#L25

The xbmc.Monitor class includes a Poller that runs every 0.2 seconds and is basically an if... else if... else if... else if... and it runs different methods depending on the criteria captured from Kodi. At the end it waits for 0.2 seconds then it runs again. You can make it wait using xbmc.Monitor().waitforAbort(timeout) - https://xbmc.github.io/docs.kodi.tv/mast...da904e8249

Depending on what you want to do I think another approach that might be useful is the button hack in Kodi, where you put a button in the focuslayout of a container, the <onfocus> will trigger immediately on any user input. You can use this to run a script instantly after a user scrolls. You can also be very granular with triggering delays by adding empty animations, if for example you want something to happen x milliseconds after the user scrolls.

Here are some I use in my skin to do various things: 

https://github.com/realcopacetic/skin.co...es.xml#L79

Line 85 I use this trick to run a script immediately on user scrolls (the script does some strong cleaning on filenames). This is much more responsive than the poller method above which would need to wait up to 200ms until the next cycle to execute the same method/script

This one with an animation delay so some properties are cleared 360ms after a user scrolls (basically one my scroll animation has finished)

https://github.com/realcopacetic/skin.co...es.xml#L79
Reply
#4
First of all: Wow! Thank you for that great help and very very useful post!
Quote:I believe the general approach with xbmc.Monitor() is to create a poller that runs every x seconds. Mine I do 0.2 seconds. it's good enough for most things but it's not instantaneous. You can see mine here which was based on bits of @jurialmunkey and "@sualfred" addons: https://github.com/realcopacetic/script....tor.py#L25 
Absolutely, not a good way to handle user inputs at all, thanks alot for clearing this and saving me a lot of time Wink
Quote:Depending on what you want to do I think another approach that might be useful is the button hack in Kodi, where you put a button in the focuslayout of a container, the <onfocus> will trigger immediately
Thank You, thats exacltly what i was looking for! Most useful are the linked code examples. Thats why i asked here, usally i try to get along myself reading the wiki etc., but these code examples are eaxctly what i needed. Immediate action when user just "touches" a control with <onfocus>. Really thanks, that saved me a lot of time just needed the right direction but with these examples: just perfect. I also digged the wiki and the Kodi Documentation, and this seems to be the right way...
Reply
#5
(2024-08-31, 11:03)iceman20k Wrote: First of all: Wow! Thank you for that great help and very very useful post!
Quote:I believe the general approach with xbmc.Monitor() is to create a poller that runs every x seconds. Mine I do 0.2 seconds. it's good enough for most things but it's not instantaneous. You can see mine here which was based on bits of @jurialmunkey and "@sualfred" addons: https://github.com/realcopacetic/script....tor.py#L25 
Absolutely, not a good way to handle user inputs at all, thanks alot for clearing this and saving me a lot of time Wink
Quote:Depending on what you want to do I think another approach that might be useful is the button hack in Kodi, where you put a button in the focuslayout of a container, the <onfocus> will trigger immediately
Thank You, thats exacltly what i was looking for! Most useful are the linked code examples. Thats why i asked here, usally i try to get along myself reading the wiki etc., but these code examples are eaxctly what i needed. Immediate action when user just "touches" a control with <onfocus>. Really thanks, that saved me a lot of time just needed the right direction but with these examples: just perfect. I also digged the wiki and the Kodi Documentation, and this seems to be the right way...

Glad it helped. One thing to keep in mind is that this technically leads to 'warnings' as opposed to 'errors' in your log for having a button in a focusedlayout. You get something like this in your log when the button is triggered: 

warning <general>: Trying to add unsupported control type 7

Basically it doesn't seem to have any negative repercussions that anyone knew of when I asked about it. And it didn't stop my skin from being submitted into the official Kodi repo, so I've continued to use it. But just so you have all the information in case you're trying to diagnose that warning line.
Reply

Logout Mark Read Team Forum Stats Members Help
Addressing (Panel) Items on the Home Window0