Thanks in advance !!!!!
var pluginObject = null;
function init()
{
var pluginObject = document.getElementById('pluginObj'); //This is object for my Plugin.
pluginObject.onstartevent = handleEvent(); // This is working
//now i am calling one function in plugin that will return NPObject using invoke default
pluginObject.startEvent(function(e) {
e.onstartEvent = handleEvent(); //This is not working ......how to make it work
});
}
function handleEvent(e)
{
if(e)
{
alert(e);
}
}
<body onload = "init()" > </body>
Here i am calling init function from body and then creating plugin object and then calling one property onstartEvent that i am taking care inside plugin. Problem is "e.onstartEvent" how to capture this object and invoke here . i am not getting it . For PluginObject i am using NPNVPlUGINOBJECT and then checking property "onstartEvent" if it is present then checking for has method and finally invoke on the PLUGIN object.
//My Plugin Code is as follows :
bool ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result)
{
char *pFunc = NPN_UTF8FromIdentifier(name);
if(!strcmp("startEvent",pFunc))
{
NPObject * argsVal = args[0].value.objectValue;
NPVariant valueToSend;
NPVariant returnValue;
valueToSend.type = NPVariantType_Object;
valueToSend.value.objectValue = this;
NPN_InvokeDefault(mNpp,argsVal,&valueToSend,1,&returnValue);
return true;
}
return false;
}
Now in HasProperty checking in the current class property named of "onstartEvent"
bool ScriptablePluginObject::HasProperty(NPIdentifier name)
{
char *pProp = NPN_UTF8FromIdentifier(name);
//Check which Properties are available
if( !strcmp( "onstartEvent", pProp ) )
{
return true;
}
return false;
}
Now in GetProperty i am finally checking and returning some integer value to the //handleEvent function
bool ScriptablePluginObject::GetProperty(NPIdentifier name, NPVariant *result)
{
VOID_TO_NPVARIANT(*result);
char *pProp = NPN_UTF8FromIdentifier(name);
//onstartEvent
if(!strcmp("onstartEvent", pProp))
{
//Calling e.onstartEvent will come here in GetProperty
NPObject * pluginObj = NULL;
NPN_GetValue(mNpp,NPNVPluginElementNPObject,&pluginObj);
NPIdentifier id = NPN_GetStringIdentifier("onstartEvent");
bool val = NPN_HasMethod(mNpp,pluginObj,id);
NPVariant value;
NPVariant retVal;
value.type = NPVariantType_Int32; //now returning some value if val is true.
value.value.intValue = 20;
if(val==true)
{
//Finally returning value to the handle Event function in JavaScript
NPN_Invoke(mNpp,pluginObj,id,&value,1,&retVal);
}
return true;
}
return true;
}