ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > FARR Plugins and Aliases

FARR C# SDK and Documentation V2 (19/10/2008)

<< < (8/11) > >>

skajfes:
Now I have a question. It concerns the new feature of adding buttons to the statusbar and context menu.
I can add an item to the statusbar with ExecuteFARRCommand() method, but how can I set the command to to tell the plugin something? In the help it says that I have to use "pcommand" launch string with some extra text as parameter, and that FARR will do a plugin->set_strvalue("pcommand",EXTRA_TEXT) call to the plugin. Now, how can I catch that call?

And another question is about adding context menu items. Help states that The "contextmenu" addmenu command must be called at a very specific time, only after farr requests it from your plugin.  This happens when your plugin received an AllowProcessTrigger call with triggermode=PrepareContextMenu.
--- End quote ---
How can I answer that call?

Thanks.

mouser:
all good questions.

let me start with pcommand.

the idea of pcommand is normally to give a way for plugins to call each other, but it can also be useful for doing a kind of callback as you suggest.  czb uses pcommand in some very clever and creative ways to do things from web pages presented to the user, since links on a web page can trigger pcommands.

as you say:

FARR will do a plugin->set_strvalue("pcommand",EXTRA_TEXT) call to the plugin. Now, how can I catch that call?
--- End quote ---

basically what happens is the EVERY plugin will receive a set_strvalue callback with ("pcommand",EXTRA_TEXT).
then the idea is that all plugins will examine the EXTRA_TEXT and decide whether they should handle it.
ONLY if a plugin wants to tell FARR that it has assumed responsibility for it will it return a TRUE, otherwise FALSE.

So lets say you wanted to implement a special callback from farr, you would give it a unique name like "skajfes_callback_doadance"
and then you would make a context menu or statusbar or web page link that was like this: "pcommand skajfes_callback_doadance:some more info here"

and then in your set_strvalue(name,value) event function that gets called by farr
you would check if name=="pcommand" and value STARTS WITH "skajfes_callback_doadance:" and if so, then the pcommand is meant for you, so you process it and return TRUE to farr.
if not, then its for some other plugin so you return false and let some other plugin try to handle it.

mouser:
Ok for question 2:

The "contextmenu" addmenu command must be called at a very specific time, only after farr requests it from your plugin.  This happens when your plugin received an AllowProcessTrigger call with triggermode=PrepareContextMenu.
--- End quote ---

you create the context menu items in the exact same way that you create status bar items; here is an example from a javascript plugin:

            FARR.setStrValue("addmenu.contextmenu","type=item|caption=Help|hint=Help for the plugin|icon=help.ico|launch=restartsearch hello\ntype=item|caption=Help2|hint=Help2 for the plugin|icon=web.ico|launch=restartsearch hello2");

and then i think you were asking WHEN you have to make this call in order to add the context menu item.  this is an important question since the contextmenu items need to be set at a very particular time, right after the user right clicks on an item.

now in order to do that, you NEED the new farr callback which was recently added (and is not yet in the C# api but i have on good authority it will be added soon):


--- ---Allow_ProcessTriggerV2(const char* destbuf_path, const char* destbuf_caption, const char* destbuf_groupname, int pluginid,int thispluginid, int score, E_EntryTypeT entrytype, void* tagvoidp, BOOL *closeafterp, int triggermode);

where triggermode is E_AllowProcessTriggerMode_PrepareContextMenu=2

so the key thing here is that the new callback ProcessTriggerV2 gets called when an item is right-clicked (not just when launched as old V1 did), and that is what you want to listen for; when that is called, thats when you need to set the addmenu.contextmenu.

joshuawood:
Thanks for the help skajfes. I've got a better idea now after look at the iTunes code some more.

I seem to need to put my code in the constructor:


--- ---public FARRTrayList(FARRCSharpPluginBase pluginBase)
            : base(pluginBase, "^tray")
        {            EnumTray.GetTrayData(out buttonData);       // populate tray data

            foreach (TrayIconData trayData in buttonData)
            {
                if (trayData.button.fsState != 8)     // only add if button is not invisible
                    SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                //if (this.Count > 10)
                //  break;
            }
}
If I put it in GetActionsCount it doesn't work. That's ok though. However, on executing a result, it does nothing except hide FARR. I have a simple MessageBox.Show() string printed at the moment (in Execute()), but the MessageBox doesn't show?

skajfes:
now in order to do that, you NEED the new farr callback which was recently added (and is not yet in the C# api but i have on good authority it will be added soon)
-mouser (January 09, 2009, 08:14 AM)
--- End quote ---
Now, that's all that I needed :)

and then in your set_strvalue(name,value) event function that gets called by farr
-mouser (January 09, 2009, 08:14 AM)
--- End quote ---
This one is for vitalyb: what is the function(method) name in c# sdk that I need to override to catch this call or is it not yet implemented?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version