The scriptlet can expose these standard DHTML events:
| onclick | onkeypress | onmousemove |
| ondblclick | onkeyup | onmouseup |
| onkeydown | onmousedown |
Tip You can define a context menu that is displayed when the user right-clicks the scriptlet at runtime. For details, see the setContextMenu method.
To work with standard events in the host application, you must write handlers in two places: one in the scriptlet to send the event, and another in the host application to capture the event.
To pass an event from the scriptlet to the host application
Note Before passing events to the container object, you can check the scriptlet's frozen property to be sure that the container object is ready to handle events.
The following scriptlet script shows how you can pass a text box's onkeyup event to the host application:
<INPUT TYPE=text ONKEYUP="passKeyUp()" NAME="t1" VALUE="">
<SCRIPT LANGUAGE="JavaScript">
function passKeyUp() {
// script statements here if required
window.external.bubbleEvent();
// further script statements here if required
}
</SCRIPT>
In the host application, the corresponding event is triggered for the scriptlet container object. Additional information about the event, such as the location of the mouse pointer or the state of keys at the time the event was triggered, is available in the script container object's event property. For example, the following Visual Basic subroutine shows how you would capture the scriptlet's onkeypress event and display the key code of a character typed in a scriptlet textbox:
Sub ScriptContainer1_onkeyup() MsgBox "The character typed was " & ScriptContainer1.event.keyCode MsgBox "The shift state was " & ScriptContainer1.event.shiftKey End Sub
In Internet Explorer, the following script does the same thing:
<SCRIPT LANGUAGE=JavaScript FOR=document EVENT=onkeyup>
alert("Key code = " + window.event.keyCode)
alert("Shift status = " + window.event.shiftKey)
</SCRIPT>
See Also
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.