Last updated

API / geotoolkit3d / tool / devicesupport / AbstractDeviceSupport / AbstractDeviceSupport

Class: AbstractDeviceSupport

devicesupport.AbstractDeviceSupport.AbstractDeviceSupport

A devicesupport class is a class that is able to listen to the specific events fired by the browser.
For example MSPointers or Touch events.

When receiving an event, it will trigger the correct generic function of the given 'target'.
Therefore it will convert 'browser-specific' events to a 'more generic' behavior.

The event passed down to the target will be the native event.
However, implementation of this class will also introduce 'plotX', 'plotY' attributes in the event.
They corresponds to the cursor/fingers/pen location converted to plot-relative coordinates.

In case of multiple cursor/fingers/pen location, the array attributes 'plotXs', 'plotYs' will also be populated accordingly.

Builtin implementations include:

  • Mouse: Supports [w3c-mouse-event](http://www.w3schools.com/jsref/dom_obj_event.asp) based devices
  • Pointer: Supports system using the [w3c-pointers](https://www.w3.org/TR/pointerevents/) architecture.
  • Touch: Supports system using the [w3c-touch](https://www.w3.org/TR/touch-events/) architecture.

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new AbstractDeviceSupport(options)

Protected new AbstractDeviceSupport(options)

Parameters

Name Type Description
optionsOptionsThe options

Overrides

EventDispatcher.constructor

Methods

dispose

dispose(): void

Dispose.

Returns

void

Inherited from

EventDispatcher.dispose


getClassName

getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getOptions

getOptions(): Required<Options>

Get abstract device support options

Returns

Required<Options>


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

EventDispatcher.hasEventListener


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

EventDispatcher.isDisposed


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

EventDispatcher.isSilent


notify

notify<E>(type, source, args?): AbstractDeviceSupport

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourceAbstractDeviceSupportof the event
Optional argsEventMap[E]arguments of the event

Returns

AbstractDeviceSupport

this

Overrides

EventDispatcher.notify


off

off<E>(type?, callback?): AbstractDeviceSupport

Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: AbstractDeviceSupport, args: EventMap[E]) => voidfunction to be called

Returns

AbstractDeviceSupport

this

Overrides

EventDispatcher.off


on

on<E>(type, callback): AbstractDeviceSupport

Attach listener on event that will be called whenever the specified event is delivered to the target

If the callback function is already in the list of event listeners for this target, the function is not added a second time.

If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: AbstractDeviceSupport, args: EventMap[E]) => voidto be called

Returns

AbstractDeviceSupport

this

Overrides

EventDispatcher.on


setOptions

setOptions(options): AbstractDeviceSupport

Set options, the given json will be merged with the object's state so that only the given options will be changed.

Parameters

Name Type Description
optionsOptionsThe options

Returns

AbstractDeviceSupport

this


setSilent

setSilent(bool): AbstractDeviceSupport

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

AbstractDeviceSupport

this

Inherited from

EventDispatcher.setSilent


setup

setup(plot, domelement, target): void

Function called to attach the device-support class to an actual plot.
Implementation should be reentrant and attach any native listener they need.

Parameters

Name Type Description
plotPlotThe plot to attach to
domelementHTMLElementThe dom element to attach to
targetAbstractToolThe tool to notify on native events

Returns

void


getClassName

Static getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


isSupported

Static isSupported(): boolean

Function called to check if this class should be used for the current context.

This will be called as part of the lookup mechanism of the DeviceSupportRegistry.
This static function should be implemented in each subclass and return true if and only if it should be used in the current context.

Typical implementation will check for the presence of some known attributes in the window or user-agent to determine the nature of the current platform/browser.

Returns

boolean