CoreMouseService

This commit is contained in:
Jörg Breitbart
2019-07-19 01:45:27 +02:00
parent d55fb1e922
commit 4858bdc464
8 changed files with 684 additions and 207 deletions
+61
View File
@@ -158,3 +158,64 @@ export interface IRowRange {
start: number;
end: number;
}
/**
* Interface for mouse events in the core.
*/
export interface ICoreMouseEvent {
/** column (zero based). */
col: number;
/** row (zero based). */
row: number;
/**
* Button the action occured. Due to restrictions of the tracking protocols
* it is not possible to report multiple buttons at once.
* Wheel is treated as a button.
* There are invalid combinations of buttons and actions possible
* (like move + wheel), those are silently ignored by the CoreMouseService.
*/
button: 'left' | 'middle' | 'right' | 'wheel' | 'none';
action: 'up' | 'down' | 'move';
/**
* Modifier states.
* Protocols will add/ignore those based on specific restrictions.
*/
ctrl?: boolean;
alt?: boolean;
shift?: boolean;
}
/**
* CoreMouseEventType
* To be reported to the browser component which events a mouse
* protocol wants to be catched and forwarded as an ICoreMouseEvent
* to CoreMouseService.
* Known types:
* - mousedown: any mousedown event
* - mouseup: any mouseup event
* - wheel: any wheel event
* - mousedrag: any mousemove event while a button is pressed
* - mousemove: any mousemove event
*/
export type CoreMouseEventType = 'mousedown' | 'mouseup' | 'wheel' | 'mousemove' | 'mousedrag';
/**
* Mouse protocol interface.
* A mouse protocol can be registered and activated at the CoreMouseService.
* `events` should contain a list of needed events as a hint for the browser component
* to install/remove the appropriate event handlers.
* `restrict` applies further protocol specific restrictions like not allowed
* modifiers or filtering invalid event types.
*/
export interface ICoreMouseProtocol {
events: CoreMouseEventType[];
restrict: (e: ICoreMouseEvent) => boolean;
}
/**
* CoreMouseEncoding
* The tracking encoding can be registered and activated at the CoreMouseService.
* If a ICoreMouseEvent passes all procotol restrictions it will be encoded
* with the active encoding and sent out.
*/
export type CoreMouseEncoding = (event: ICoreMouseEvent) => string;