Velocity API: WLEvent.on()

Version 2

    Return To Index

    WLEvent.on()

    Overview

    Set an event handler (a function) for the current scope or a specified scope.

    Added in version 1.2.0

    Format

     

    WLEvent.on(eventName, funcRef, scope, addFirst);
    ParameterDescriptionTypeRequiredNotes
    eventNameThe name of the event.StringRequiredSee Event Name Options.
    funcRefThe function that triggers when the named event is triggered. Functions should take one parameter that is an event object.FunctionRequired
    scopeThe scope this event is added to.StringOptionalIf no value is provided, the current scope is used. See WLEvent.registerScope() Velocity Scopes.
    addFirstShould the event should be inserted at the highest priority position.BooleanOptionalIf no value is provided, this parameter defaults to false.

     

    Example

    /* When a scanning event occurs for the session, the anonymous 
    * function is called.
    */
      
    WLEvent.on("Scan", function(event) {
        Logger.debug("Scan of data: " + event.data);
    }, "session");

    Event Name Options

    The event object is passed as the first parameter to an event handler (a function). The event object can be used to get more information about the event. The event object can also be used to pass results back after processing.

    "EnterScope"

     

    Triggers the event when a scripting scope is entered. Fires after the scope is added to the scope stack, but before executing all functions registered for the scope.

    Event PropertyTypeDescription
    scopeStringThe name of the scope entered.

     

    "ExitScope"

     

    Triggers the event when a scripting scope has exited.

    Event PropertyTypeDescription
    scopeStringThe name of the scope entered.

     

    "Scan"

     

    Triggers the event when scan data is received from the scanner. This event may be used to alter scan data before it is sent to the host.

    Event PropertyTypeDescription
    dataStringThe scan data. This property can be modified to change the data before it is sent.
    typeStringThe symbology type.

     

    "OnKey<HHHH>"

     

    Triggers the event when a registered key is pressed on either the software or hardware keyboard. This event takes precedence over the general-purpose Key event. The values entered in place of “HHHH” must be a valid hex code. For example: OnKey<000D>.

    Event PropertyTypeDescription
    keyCodeStringThe decimal key code as a string. This property can be modified to change how this key is handled.
    eventHandledBooleanCan be set to disable default processing of this key.

     

    "Key"

     

    Triggers the event when a general purpose key handler is registered. All software and hardware presses will be sent for this event.

    Event PropertyTypeDescription
    keyCodeStringThe decimal key code as a string. This property can be modified to change how this key is handled.
    eventHandledBooleanCan be set to disable default processing of this key.

     

    "Beep"

     

    Triggers the event when a beep is about to play.

    Added in version 1.2.4

    Event PropertyTypeDescription
    typeStringThe beep type. "2" for Error Beep, "3" for Scan Beep, "4" for Standard Beep.
    eventHandledBooleanCan be set to disable default processing of this beep.

     

    "ScreenUpdated"

     

    Is fired whenever a screen update is received from the host system.

    Added in version 1.2.104

    Event PropertyTypeDescription
    NONEnilN/A

     

    "SpeechResult"

     

    Is fired whenever a speech result is received from the voice recognition engine.

    Added in version 1.2.104

    Event PropertyTypeDescription
    templateStringIf a template has been selected this will contain the template name, otherwise it will be undefined.
    confidenceNumberThe confidence level returned by the voice recognizer.
    grammarStringThe grammar that this speech result belongs to, may be undefined when the result is a voice command.
    startRuleStringThe rule that this speech result belongs to, may be undefined when the result is a voice command.
    userIdNumberThe assigned ID value from the grammar directive !id.
    resultStringThe value that should be sent to the host, this may be a key macro sequence as defined by a voice command.
    speechResultStringThe original value that was recognized by the voice engine.
    eventHandledBooleanCan be set to disable default processing of this event.