MediaPortal Forums HTPC/MediaCenter

Go Back   MediaPortal Forum » MediaPortal 1 » Community Skins and Plugins » Plugins


Plugins Plugins developed and maintained by users. Want to create your own plugin? Start a thread in here.

Reply
 
Thread Tools Display Modes
Old 2006-06-19, 01:42   #1 (permalink)
Portal Member
 
zombiepig's Avatar
 
Join Date: Mar 2005
Location: Melb, Aus
Age: 27
Posts: 408
Thanks: 0
Thanked 0 Times in 0 Posts

Country:


Default processing button click in a plugin

i'm wanting to add a button to an existing screen (myvideosinfo), which when clicked runs a function from my process plugin.

at the moment the way i'm doing this is manually adding the button to the skin xml and giving it a new id (say 5555). then in the plugin Start() function i've got a line:
GUIWindowManager.Receivers += new SendMessageHandler(OnMessage);

the OnMessage function looks like this:

private void OnMessage(GUIMessage message)
{
if (message.Message == GUIMessage.MessageType.GUI_MSG_CLICKED && message.SenderControlId == 5555)
{
// run my function
}
}

is this the correct way of doing this? is there a better way?
zombiepig is offline   Reply With Quote
Old 2006-06-19, 16:01   #2 (permalink)
Portal Member
 
Join Date: Apr 2005
Location: Southeast
Age: 36
Posts: 606
Thanks: 6
Thanked 35 Times in 24 Posts

Country:


Default Re: what's the correct way to do this?

Quote:
Originally Posted by EqualRightsForWerewolves
is this the correct way of doing this? is there a better way?
I am not sure about correct or better but
they way I have usually seen it done is to put it into
the override of OnClicked and check the control.
(If you are changing code in an existing plugin the override is probably already there)

So after you add the button to the skin.xml file
something like the code below should work.


Code:
[SkinControlAttribute(5555)] protected GUIButtonControl btnRunMyProcessPlugin = null;

protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
{
   base.OnClicked(controlId, control, actionType);
   
   if (control == btnSomeOtherButton)
   {
      // 
   }
   else if (control == btnRunMyProcessPlugin)
   {
      // Insert code here
   }
}
HTH
patrick
patrick is offline   Reply With Quote
Old 2006-06-20, 02:45   #3 (permalink)
Portal Member
 
zombiepig's Avatar
 
Join Date: Mar 2005
Location: Melb, Aus
Age: 27
Posts: 408
Thanks: 0
Thanked 0 Times in 0 Posts

Country:


Default

i just tried putting the code you suggested in the plugin but i'm getting a compilation error:

"'MyHTTrailers.Class1.OnClicked(int, MediaPortal.GUI.Library.GUIControl, MediaPortal.GUI.Library.Action.ActionType)': no suitable method found to override C:\Documents and Settings\Nyall\My Documents\Visual Studio 2005\Projects\MyHTTrailers\MyHTTrailers\Class1.cs 267 33 MyHTTrailers
"

is there something I'm missing?
zombiepig is offline   Reply With Quote
Old 2006-06-20, 15:33   #4 (permalink)
Portal Member
 
Join Date: Apr 2005
Location: Southeast
Age: 36
Posts: 606
Thanks: 6
Thanked 35 Times in 24 Posts

Country:


Default

Is your class inheriting from MediaPortal.GUI.Library.GUIWindow?

Code:
public class Class1 : GUIWindow
{
}
HTH,
patrick
patrick is offline   Reply With Quote
Old 2006-06-21, 02:09   #5 (permalink)
Portal Member
 
zombiepig's Avatar
 
Join Date: Mar 2005
Location: Melb, Aus
Age: 27
Posts: 408
Thanks: 0
Thanked 0 Times in 0 Posts

Country:


Default

ok - i got it to compile but the OnClicked function isn't triggering. is this because my plugin is a process plugin which i'm trying to trigger from another skin page, and doesn't have it's own page?

also - is there any way to add an item to an existing mp context menu from a plugin?

thanks for all the assistance btw!
zombiepig is offline   Reply With Quote
Old 2006-06-21, 16:02   #6 (permalink)
Portal Member
 
Join Date: Apr 2005
Location: Southeast
Age: 36
Posts: 606
Thanks: 6
Thanked 35 Times in 24 Posts

Country:


Default

Quote:
Originally Posted by EqualRightsForWerewolves
is this because my plugin is a process plugin which i'm trying to trigger from another skin page, and doesn't have it's own page?
I think I read your first post too quickly...Sorry

I thought you were creating or modifying the code
in a windows plugin to start something in a process
plugin when you said adding a button to an existing screen.

So pretty much ignore everything I said...

It looks like you were doing it right.
The only other thing you may want to do is check
if the current window is the window you added the
button to so you do not act on the clicks on any
button with id=5555.

Quote:
Originally Posted by EqualRightsForWerewolves
also - is there any way to add an item to an existing mp context menu from a plugin?
Not sure on that one.

Again, sorry I caused you extra work.

patrick
patrick is offline   Reply With Quote
Reply

Bookmarks

Tags
button, click, plugin, processing

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[BUG] Unable to scan TV chanels and radio Bram pre 1.0 RC1 0 2006-11-05 14:45
Issue with My TV, My Videos and Web Browser Efros The old Bugreport Forum 15 2006-05-15 22:01
After first time entering .apefolder all files is unknown. PHN2 The old Bugreport Forum 1 2006-03-15 17:28
Gathering topical infos about plugins (To: authors & use tomtom21000 Plugins 2 2006-02-05 00:20
Plugin example doesnt show in list Anonymous Plugins 5 2005-08-13 12:12


All times are GMT +1. The time now is 05:46.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 Protected by Akismet Blog with WordPress
Advertisement System V2.6 By   Branden