Altova Authentic 2024 Browser Edition

OnKeyboardEvent

Home Prev Top Next

Event: OnKeyboardEvent (eKeyEvent as SPYKeyEvent, nKeyCode as Long, nVirtualKeyStatus as Long) as Boolean

 

XMLSpy scripting environment - VBScript:

Function On_AuthenticKeyboardEvent(eKeyEvent, nKeyCode, nVirtualKeyStatus)

 ' On_AuthenticKeyboardEvent = True  ' to cancel bubbling of event

End Function

 

XMLSpy scripting environment - JScript:

function On_AuthenticKeyboardEvent(eKeyEvent, nKeyCode, nVirtualKeyStatus)

{

 // return false;  /* to cancel bubbling of event */

}

 

XMLSpy IDE Plugin:

IXMLSpyPlugIn.OnEvent (30, ...)        // nEventId = 30

 

Description

This event gets triggered for WM_KEYDOWN, WM_KEYUP and WM_CHAR Windows messages.

 

The actual message type is available in the eKeyEvent parameter. The status of virtual keys is combined in the parameter nVirtualKeyStatus. Use the bit-masks defined in the enumeration datatype SPYVirtualKeyMask, to test for the different keys or their combinations.

 

REMARK: The following events from the scripting environment and IDE Plugin of XMLSpy are still supported but become obsolete with this event:

On_AuthenticKeyUp()                IXMLSpyPlugIn.OnEvent (13, ...)        // nEventId = 13

On_AuthenticKeyDown()                IXMLSpyPlugIn.OnEvent (12, ...)        // nEventId = 12

On_AuthenticKeyPressed()        IXMLSpyPlugIn.OnEvent (14, ...)        // nEventId = 14

 

 

Examples

' ----------------------------------------------------------------------------

' VB code snippet - connecting to object level events

' ----------------------------------------------------------------------------

' access XMLSpy (without checking for any errors)

Dim objSpy As XMLSpyLib.Application

Set objSpy = GetObject("", "XMLSpy.Application")

 

' this is the event callback routine connected to the OnKeyboard

' event of object objView

Private Function objView_OnKeyboardEvent(ByVal i_keyEvent As Long, ByVal io_pnKeyCode As Long, ByVal i_nVirtualKeyStatus As Long) As Boolean

  If ((i_keyEvent = XMLSpyLib.spyKeyUp) And ((i_nVirtualKeyStatus And XMLSpyLib.spyCtrlKeyMask) <> 0)) Then

       MsgBox ("Ctrl " & io_pnKeyCode & " pressed")

       objView_OnKeyboardEvent = True

  Else

       objView_OnKeyboardEvent = False

  End If

End Function

 

' use VBA keyword WithEvents to connect to object-level event

Dim WithEvents objView As XMLSpyLib.AuthenticView

Set objView = objSpy.ActiveDocument.AuthenticView

 

' continue here with something useful ...

' and serve the windows message loop

 

© 2017-2023 Altova GmbH