API / geotoolkit3d / tool / devicesupport / AbstractDeviceSupport / 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.
↳
AbstractDeviceSupport
Constructors
Methods
Constructors
• Protected new AbstractDeviceSupport(options)
| Name | Type | Description |
|---|---|---|
options | Options | The options |
EventDispatcher.constructor
Methods
▸ dispose(): void
Dispose.
void
▸ getClassName(): string
string
▸ getOptions(): Required<Options>
Get abstract device support options
Required<Options>
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
EventDispatcher.hasEventListener
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): AbstractDeviceSupport
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | AbstractDeviceSupport | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: AbstractDeviceSupport, args: EventMap[E]) => void | function to be called |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: AbstractDeviceSupport, args: EventMap[E]) => void | to be called |
this
▸ 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.
| Name | Type | Description |
|---|---|---|
options | Options | The options |
this
▸ setSilent(bool): AbstractDeviceSupport
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ 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.
| Name | Type | Description |
|---|---|---|
plot | Plot | The plot to attach to |
domelement | HTMLElement | The dom element to attach to |
target | AbstractTool | The tool to notify on native events |
void
▸ Static getClassName(): string
string
▸ 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.
boolean