Guicontrolsdemo ? come out, come out, whereever you are? (1 Viewer)

gpnash

Portal Pro
March 2, 2015
70
16
65
Linden, Michigan
Home Country
United States of America United States of America
updated my previous post to my latest attempt.

Formatting problems are now all taken care of.

Added a handler for onItemSelected to each guilistitem and now....

using the remote downarrow button thru the list selects each item it passes.
so does using the remote cursor controls or just about everything else.

at this point I figure I'm dong something incredibly wrong and without better documentation I'm afraid I'm done. This has been an extremely rough ride, almost as difficult as the windows UWP arena. The windows program I'm trying to port required less than a day to write using windows forms goes against the mediaportal databases and works like a charm. I've been at this for a little over two days now and still don't have a working user interface. that's not a good sign.

If anyone can see where I went wrong I'd appreciate a heads up. This has to be simpler than I had to make it.

thanks.
 
Last edited:

mm1352000

Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Hi

    at this point I figure I'm dong something incredibly wrong and without better documentation I'm afraid I'm done.
    The previous statement about using the remote down arrow makes it seem like you're succeeding. Therefore this following statement is highly confusing.
    What exactly is the problem? :confused:
    In your previous reply you mention trying to figure out which list item was clicked on. Are you still struggling with that, or...?
    (If yes, there are many many examples of how this works in the main repo as well as for 3rd party plugins. Have you looked at them?)
    Please clarify.

    This has been an extremely rough ride, almost as difficult as the windows UWP arena. The windows program I'm trying to port required less than a day to write using windows forms goes against the mediaportal databases and works like a charm. I've been at this for a little over two days now and still don't have a working user interface. that's not a good sign.
    While I accept your opinion, there are some obvious advantages with WinForms (your familiarity/experience, breadth of user base and corresponding availability of examples etc.) which in my opinion make this a pretty unfair comparison!

    This has to be simpler than I had to make it.
    The easiest way to develop a new plugin is to start with a plugin with similar functions or UI elements as an example or base. From the way you've written, it sounds like you've taken the much harder approach of attempting to start from scratch. I hope I'm mistaken about this, but it also seems like you haven't recognised that existing plugin code is there to be copied and pasted or used as a template. In any case, you certainly haven't given very much information about what you're trying to achieve (overall goal and design), and that does make it more difficult to help you.

    Regards,
    mm
     

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    Hey, thanks for replying....
    1) haven't been able to find any real examples of a plugin written in visual basic.

    What I was trying to do is display a list of possible shows from the EPG that were flagged by my process to update the EPG.
    Where I started running into problems is the lack of documentation as to the sequence of events in the lifecycle of a plugin.
    With windows forms there are events that are called in order during activation and shutdown and "random" events (messages) that can occur at just about any time.
    the process for handling those events is well documented and pretty much straight forward. ASP.net has a similar lifecycle. much more complex, not as well documented and probably wrong about 1/3 of the time.
    What I need to know and couldn't find out by crawling thru the MP1 or 2 source was...
    what is a plugin really supposed to do when it starts (the documentation in the wiki is obsolete and wrong)
    What events am I required to catch and process. What events can I catch and process.
    at the moment it seems that only the messages event is consistent; for instance INIT is never called, but there is an init message that comes along.

    I'd expect that the plugin INIT (or whatever it is really called) would be called once.
    That there'd be a LOAD (possibly pageload?) that would be called when the user selected the plugin
    and that any control on the form (skin) would produce a message.

    when I populate the guilistcontrol (when I get the init message) I can see the list.
    moving the mouse (without clicking on anything) or using the remote to move between controls moves between each of the controls however using the left/right or OK buttons do not cause any message or event to fire. I basically have a pretty list and no way to select anything on it. the mouse buttons and OK do select the single button on the page.

    if I add a handler to each listitem moving the mouse or using the remote acts as if you have selected each item you pass over. the onitemselected event is fired for every listitem the mouse goes over.
    It should only fire if the listitem is selected

    sorry if it sounds like I'm grousing... I've just haven't had a learning curve this steep since I left xedit behind for visual studios IDE. (kicking and screaming btw.)
    I'd be happy to read examples/documentation but I haven't been able to find any that were relevant. there isn't even an example of setting up a multicolumn list (another user provided insight there)
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    1) haven't been able to find any real examples of a plugin written in visual basic.
    Honestly I didn't think C# and VB were so wildly different that this would present a serious barrier. Obviously C# to VB converters exist. We do also have a VB-specific guide with full plugin code in the wiki. If you found that guide to be inadequate, perhaps you could say how/why so that it could be improved.

    To more directly address your point...
    I'm not a plugin developer myself, so I'm not the best authority on this. AFAIK most MP plugins are written in C#. However a quick look at the plugin repo does turn up a few VB results. Were they also inadequate?

    Where I started running into problems is the lack of documentation as to the sequence of events in the lifecycle of a plugin.
    It's not very complex, especially if you're starting from an appropriate base/example. I suggest you take a look at the GUIWindow class (ie. the base class for all window plugins) virtual methods and their comments. If it still isn't clear enough, please feel free to ask specific questions.

    With windows forms...
    Yes I'm familiar.

    the process for handling those events is well documented and pretty much straight forward.
    Please keep in mind that we're a much smaller organisation than Microsoft. We're not able to match Microsoft's documentation standards. If you were expecting that level of documentation, you're bound to be disappointed.

    What I need to know and couldn't find out by crawling thru the MP1 or 2 source was...
    Note that MP1 and MP2 are totally different. If you're developing an MP1 plugin, crawling the MP2 code is a waste of time.

    what is a plugin really supposed to do when it starts...
    As it says in the GUIWindow Init() comment (and as you'd see from every plugin implementation), you must call Load() to load the skin file. Other than that it's completely up to you. Do whatever is relevant/appropriate for the function of your plugin.

    (the documentation in the wiki is obsolete and wrong)
    Which specific documentation are you referring to (please provide a link and/or quote), and why do you think it's obsolete and wrong?

    What events am I required to catch and process.
    None that I'm aware of. As with WinForms, it's up to you to decide what is relevant for your implementation.

    What events can I catch and process.
    From OnAction():
    https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/guilib/Action.cs

    From OnMessage():
    https://github.com/MediaPortal/MediaPortal-1/blob/master/mediaportal/Core/guilib/GUIMessage.cs

    This info is easily found using Visual Studio "go to definition" on the OnAction() and OnMessage() parameter types.
    Obviously there are other event handler methods provided by GUIWindow too (OnClicked() etc.). You can see these for yourself by examining the GUIWindow method list.

    at the moment it seems that only the messages event is consistent; for instance INIT is never called, but there is an init message that comes along.
    Init() is definitely called. If you're not receiving the call, I'd guess that you're not overriding it correctly or MP is treating your plugin as incompatible because you haven't assigned compatibility info. Can't know for sure without access to full code.

    I'd expect that the plugin INIT (or whatever it is really called) would be called once.
    Correct, Init() is called once.

    That there'd be a LOAD (possibly pageload?) that would be called when the user selected the plugin
    Yes, OnPageLoad(). That's two for two; it's really not that hard! :)

    and that any control on the form (skin) would produce a message.
    Produce a message when... ?

    moving the mouse (without clicking on anything) or using the remote to move between controls moves between each of the controls however using the left/right or OK buttons do not cause any message or event to fire.
    Do you mean that focus doesn't move, or just that you don't get a notification that the focus has moved?
    Are you handling the corresponding actions (ACTION_MOVE_LEFT/UP/RIGHT/DOWN etc.)?

    if I add a handler to each listitem moving the mouse or using the remote acts as if you have selected each item you pass over. the onitemselected event is fired for every listitem the mouse goes over.
    It should only fire if the listitem is selected
    This behaviour is as designed. If you want to be notified when an item is clicked on (or equivalently: when OK/enter is pressed while an item is highlighted), override GUIWindow OnClicked().

    sorry if it sounds like I'm grousing... I've just haven't had a learning curve this steep since I left xedit behind for visual studios IDE. (kicking and screaming btw.)
    No need to apologise. I just honestly don't understand why you think the learning curve is so steep. You only have to override one class (GUIWindow). The code is fully available with examples (albeit mostly in C# rather than VB), and if the documentation isn't clear enough, you can check how it all hangs together using VS "find all references" or "view call hierarchy". Naturally there is human help available too. :)

    I'd be happy to read examples/documentation but I haven't been able to find any that were relevant.
    For the sorts of questions you're currently asking (about initialisation/loading and event handling), I would have thought that almost every single plugin that's ever been created would be relevant. The built-in videos, music and pictures plugins all have lists, as does the TV plugin (recorded TV and radio). Granted those lists may not be as complex as you want yours to be, but they'll certainly answer all your questions about item selection.

    there isn't even an example of setting up a multicolumn list (another user provided insight there)
    Sure there is! As ajs said, the standard video and music plugins (and pictures, and TV... etc.) use the exact same strategy for presenting multi-aspect/detail items that he so kindly described for you. Granted if you personally haven't used those plugins then you might not know to look at them... but respectfully, to say that there are no examples at all isn't accurate.

    Please don't hesitate to ask if you have any further questions. The more specific you can be, the easier it is to answer.
     

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    The example I started with was the one from the vb sample in the wiki http://wiki.team-mediaportal.com/1_...loper's_Guide/1_Develop_a_Plugin/Visual_Basic

    The only reason I mentioned MP2 was, if I was going to have to go to school to learn how the plugin interface works, I'd have preferred to learn the new way rather than have to start over in a year or so. The research I've done over the last couple of days tells me that my MP2 days after further off than that.

    Don't know what c# code you're looking at but I've been looking thru the MP1 > windowsplugins > music code all day and it's so much more complex than any thing I'm trying I can't find the pieces that would apply. Segments of definitions (that you get when using go to definition or find references) don't explain why things are working the way they are. they give you a clue as to how to call a function but not near enough.
    I had some difficulty in the beginning with overloads/overrides on INIT and OnPageLoad which caused them not to work. the MP1 code helped there a lot and now at least that's functioning correctly. interaction with the gui is a issue. It would be nice to have something that outlines the level of interaction needed. Back in the day I had to code every bit and byte that went thru the 3705 to make it to the IBM mainframe, moving ahead windows forms rolls things up choc-full-o-nuts and hands it to you. I'm suspecting MP is smack-dab in the middle of those two.

    so the question becomes.. I've got my button, and list displayed on the page. JoeAverage grabs his remote or mouse or presses the down arrow on the keyboard and focus moves from my button to the guilistcontrol's firstitem. I know if that key is pressed one more time the next item is highlighted and my code is hit with an OnSelectionChanged event (I added a handler to each guilistitem) I didn't expect that. I expected to be notified when the item was selected (navigated to and a button or keypress to select) So I'm doing it wrong, no surprise there.
    I can't find in the music code where anything like this is done at all. I think what I need to be doing is examining the MSG's (onMessage) but I haven't been able to find something that differentiates between moving down the list of items from selecting one of them. Based on what you said earlier it sounds like I need to set OnClick instead of OnSelectedChanged. it also seems I've been focused on the wrong control GUIListControl when I should be looking at GUIWindow.

    I appreciate your patience. The reason I do things the long and hard way is so that I can expose myself (well, not that way) to as much of the subject as possible. There are quite a few things that I have in the works and some of them will never work (based on MP2's direction). By digging thru the mess I'm making I also find solutions for those problems. Not the most efficient way to work, but I'm retired and live with a blind cat so who cares.

    thanks again.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Don't know what c# code you're looking at but I've been looking thru the MP1 > windowsplugins > music code all day and it's so much more complex than any thing I'm trying I can't find the pieces that would apply.
    My advice: pick one window/class - ideally one that uses a list such as GUIMusicFiles - and simply notice:
    1. Which GUIWindow functions are overriden.
    2. Which actions and messages are handled.
    It shouldn't take more than 10 minutes to do that. The other detail is fluff that you don't need to care about. Don't try to understand everything; you'll get overwhelmed, and like I say, you don't need to understand it (because it's context-specific stuff).

    I had some difficulty in the beginning with overloads/overrides on INIT and OnPageLoad which caused them not to work. the MP1 code helped there a lot and now at least that's functioning correctly.
    Good. :)

    Back in the day I had to code every bit and byte that went thru the 3705 to make it to the IBM mainframe, moving ahead windows forms rolls things up choc-full-o-nuts and hands it to you. I'm suspecting MP is smack-dab in the middle of those two.
    Nah, MP is simpler than both: high level like WinForms, but far less components/controls... and the components/controls are also far simpler (less properties and events/messages/actions). I can't think of any similarities to a 3705 environment.

    I know if that key is pressed one more time the next item is highlighted and my code is hit with an OnSelectionChanged event (I added a handler to each guilistitem) I didn't expect that. I expected to be notified when the item was selected (navigated to and a button or keypress to select) So I'm doing it wrong, no surprise there.
    As per my previous reply: override the GUIWindow OnClicked() method if that's what you want to be notified about.

    I can't find in the music code where anything like this is done at all.
    As above: look for the overrides. There are OnClicked() handlers in many of those windows including GUIMusicFiles:
    https://github.com/MediaPortal/Medi.../WindowPlugins/GUIMusic/GUIMusicFiles.cs#L876

    I think what I need to be doing is examining the MSG's (onMessage) but I haven't been able to find something that differentiates between moving down the list of items from selecting one of them.
    Can we please agree on terminology. It's going to make it much easier for us to understand each other. In this particular context (other contexts may vary), what you're calling "moving down the list" is called "selection" in MP parlance, and what you're calling "selecting" is called "clicking".
    You figured out how to be notified about selection (moving down the list): via the GUIListItem OnItemSelected event.
    I've told you how to be notified about clicking (selecting): via the GUIWindow OnClicked() method.
    This should be done and dusted now, so lets move on.

    it also seems I've been focused on the wrong control GUIListControl when I should be looking at GUIWindow.
    Yes and no.

    From the description of your interface, you have a button and a list. Therefore you'll have GUIButtonControl and GUIListControl controls within a GUIWindow... in exactly the same way as you'd have a Button and a ListView component within a Form if this were WinForms. MP controls also have properties (eg. labels) like WinForms components. You shouldn't have any trouble understanding that as it's very similar and intuitive.

    As is explained in the wiki and GUIWindow code comments, notifications from controls (ie. in your case the button and list) are generally passed through the parent window's OnAction() or OnMessage() methods. The OnItemSelected event you found is an exception. This is different from a WinForms mentality where each component has a ton of events. In that sense, yes you need to focus on on GUIWindow to know about OnAction(), OnMessage(), OnClicked() etc... but it's still the controls that are sending actions, messages and events through those methods, and the controls still have their properties (labels, tags etc.), so you shouldn't ignore them. A balanced approach is appropriate.

    Segments of definitions (that you get when using go to definition or find references) don't explain why things are working the way they are. they give you a clue as to how to call a function but not near enough.
    ...
    It would be nice to have something that outlines the level of interaction needed.
    The above is as good as you're going to get from me. General exploration of "the long and hard way" is great - to be encouraged if you're interested and enjoy learning! Unfortunately I just don't have the time to travel that way with you. I can only commit to attempting to answer specific questions. That's the only way I can keep to a sane level of commitment to this project. ;)

    thanks again.
    You're welcome. :)
     
    Last edited:

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    lol, I appreciate the time you've spent on this. I guess I'm just overly dense. Been going thru GUIMUSICFILES for over two hours now and it really hasn't helped at all.
    There's a façade control in use there that I'm using. It seems all of the selecteditem logic depends on it as none of the methods/variables on in the guilistcontrol that I am using.
    if the onselecteditem handler is active for a listitem, every chance of focus made by user on the list results in selected item. In the onclicked event I'll get a notification that the guilistcontrol has been clicked, not the individual item and it only seems to work once.
    I apologize for taking up your time. I'll be looking at a couple of the other plugins you mentioned to try and see what they've got in common around item selection in hopes that a ray of sunlight will shine through.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    There's a façade control in use there...
    Ahhh, bad example. Grep the code for GUIListControl; there'll be better examples.

    In the onclicked event I'll get a notification that the guilistcontrol has been clicked, not the individual item
    GUIListControl has properties "SelectedListItem" and "SelectedListItemIndex". When you get the event for the list control, you can check which item was clicked by using the property.
     

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    That was the missing piece... when using the guilistcontrol use selectedlistitem not selecteditem. I removed the added handlers, updated the onmessage and onclicked events and everythings working the way it should. the event can be handled in either onmessage or onclick. if you handle it in onmessage make sure to return true (says you've handled the message) or both will fire for the same click (in my case selecting and then unselecting the item).

    I've updated my earlier posting with the final vb test code and skin I was using. here's what the screen looks like :)
    now for the work behind the curtain... THANK YOU!
    upload_2016-11-19_7-24-53.png
     

    Users who are viewing this thread

    Top Bottom