TP_WebKit

Hotfix libraries for Xojo Web 2.0

WebFocus captures focus events on WebTextArea and WebTextField to work around feedback case #61985 - GotFocus and LostFocus events don't fire

WebKey brings KeyDown events back to Xojo Web 2.0. Add the control to any WebPage or WebContainer to track keys on that page.

WebMouse fills the need for mouse events on any control in Xojo Web 2.0. The class can track move, click, enter, and exit events. These events are sent to the server for developers to handle as necessary.

MessageAllSessions allows developers to easily send a message to each connected WebSession. Additionally, the session that sent the message receives a message sent confirmation.

MouseDown, MouseEnter, and MouseExit events are sent as soon as they happen. MouseDown will cancel any queued move event, and send the MouseDown event with coordinates. This prevents out of order events.

pointer

Using TP_WebKit.WebFocus

Listen for Focus Events
  1. Drag an instance of TP_WebKit.WebFocus onto a WebPage or WebContainer that holds the WebTextArea or WebTextField you want to listen for focus events on.
  2. Optionally use the ControlReady event to automatically listen for key events as soon as possible.
  3. Call AddListener on an instance to begin listening for key events.
    WebFocus1.AddListener(myTextField)
Stop Listening
  1. Detach the listener for the WebTextControl
    TP_WebFocus1.RemoveListener(myTextField)

Using TP_WebKit.WebKey

Listen for Key Events
  1. Drag an instance of TPWebKey onto a WebPage or WebContainer you want to listen for key events on.
  2. Optionally use the ControlReady event to automatically listen for key events as soon as possible.
  3. Call Listen on an instance to begin listening for key events
    TP_WebKey1.Listen
Stop Listening
  1. Call Deafen on a listening instance to stop listening for key events
    TPWebKey1.Deafen

Using TP_WebKit.WebMouse

Listen for Mouse Events
  1. Drag TP_WebMouse to a WebPage or WebContainer
  2. Select events to listen for using the IDE options
  3. Attach to a WebControl to listen for events
    TP_WebMouse1.AddListener(ctlSomeControl)
  4. The TP_WebMouse instance will raise Xojo events for the tracked mouse events

Note: The Opening event is too soon to listen. Use the Shown event of the page or container to attach listeners. It is also safe to attach listeners any time after the Shown event has occurred.

Stop Listening
  1. Detach the listener for the WebControl
    TP_WebMouse1.RemoveListener(ctlSomeControl)

Using TP_WebKey

Listen for Key Events
  1. Drag an instance of TPWebKey onto a WebPage or WebContainer you want to listen for key events on.
  2. Optionally use the ControlReady event to automatically listen for key events as soon as possible.
  3. Call Listen on an instance to begin listening for key events
    TP_WebKey1.Listen
Stop Listening
  1. Call Deafen on a listening instance to stop listening for key events
    TPWebKey1.Deafen

Class Definition

Events

Name Description
MouseDown(WebControl, X, Y) Raised when the user has pressed the mouse button down. The X and Y parameters passed are the mouse position of the click relative to the tracking control.
MouseEnter(WebControl) Raised when the mouse enters the WebControl that is passed.
MouseExit(WebControl) Raised when the mouse leaves the WebControl that is passed.
MouseMove(WebControl, X, Y) Raised when the user moves the mouse and has stopped moving. This event is only raised when the mouse stops moving for 200ms. The stop time can be adjusted in the Javascript source. A MouseDown event will cancel any queued MouseMove event. The X and Y parameters passed are the mouse position relative to the tracking control.

Methods

Name Description
AddListener(WebControl) Add a mouse events listener for the passed control. Will listen for the events selected.
FindListener(String) as WebControl Internal method for finding the listening WebControl by ControlID.
RemoveListener(WebControl) Stops listening for all events from the passed control. This can be useful for reducing traffic and optimization. No errors are raised if the control isn't actively listening.

Properties

Name Description
PageX as Integer The global X coordinate of the mouse on the page. This is updated when tracking MouseMove events, and can be checked on demand.
PageY as Integer The global Y coordinate of the mouse on the page. This is updated when tracking MouseMove events, and can be checked on demand.
TrackMouseDown as Boolean Set True to track MouseDown events.
TrackMouseEnter as Boolean Set True to track MouseEnter events.
TrackMouseExit as Boolean Set True to track MouseExit events.
TrackMouseMove as Boolean Set True to track MouseMove events.

Warning: Sending mouse and key events to the server consumes a lot of traffic and can be considered wasteful. This project is made available to developers to help build their project, but does not provide performance protection. It is up to the developer to ensure their project has enough resources.