ISDBScriptControl::RegisterEvent: Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
No edit summary
 
m (note about registering events to ui_object.Common)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{MethodDeclaration|SDBScriptControl|ISDBScriptControl|Sub RegisterEvent(ObjectVar As Object, EventName As String, HandlerName As String)}}
{{MethodDeclaration|SDBScriptControl|ISDBScriptControl|Sub RegisterEvent(ObjectVar As Object, [[SDBApplication#ISDBApplicationEvents_members|EventName]] As String, HandlerName As String)}}


===Parameters===
===Parameters===
Line 5: Line 5:
{{MethodParameters  
{{MethodParameters  
  |ObjectVar |Object |Object of the event
  |ObjectVar |Object |Object of the event
  |EventName |String |Event name (string)
  |EventName |String |Event name – check manual for actual event names for given object
  |HandlerName |String |Procedure name of the handler (string)}}
  |HandlerName |String |Name of the handler procedure as string}}


===Method description===
===Method description===


Registers COM object event to be handled by a script.
Registers COM object event to be handled by a script.  


===Example code===                  
'''JScript note:''' Method does not accept anonoymous functions or callbacks. A handler function must be defined within global script scope. Then handler function's name should be passed to the method.
 
'''UI events note:''' Events from [[SDBUICommon#ISDBUICommonEvents_members|SDBUICommon]] class should be registered to the <tt>ui_object.Common</tt> property and not to the <tt>ui_object</tt> itself.
 
===Example code===
VBScript:
<source lang="vb">
<source lang="vb">
Sub ShutdownHandler
  ' Event code goes here...
End Sub
Script.RegisterEvent SDB, "OnShutdown", "ShutdownHandler"
Script.RegisterEvent SDB, "OnShutdown", "ShutdownHandler"
</source>
JScript:
<source lang="javascript">
function shutdown_handler() {
  // Event code goes here...
};


Sub ShutdownHandler
Script.RegisterEvent(SDB, 'OnShutdown', 'shutdown_handler');
  ' Event code goes here....
End Sub
</source>
</source>



Latest revision as of 22:08, 20 April 2013

CoClass SDBScriptControl, Interface ISDBScriptControl

Sub RegisterEvent(ObjectVar As Object, EventName As String, HandlerName As String)


Parameters

Name Type Description
ObjectVar Object Object of the event
EventName String Event name – check manual for actual event names for given object
HandlerName String Name of the handler procedure as string


Method description

Registers COM object event to be handled by a script.

JScript note: Method does not accept anonoymous functions or callbacks. A handler function must be defined within global script scope. Then handler function's name should be passed to the method.

UI events note: Events from SDBUICommon class should be registered to the ui_object.Common property and not to the ui_object itself.

Example code

VBScript:

Sub ShutdownHandler
  ' Event code goes here...
End Sub

Script.RegisterEvent SDB, "OnShutdown", "ShutdownHandler"

JScript:

function shutdown_handler() {
  // Event code goes here...
};

Script.RegisterEvent(SDB, 'OnShutdown', 'shutdown_handler');