@eclipse-scout/core
Version:
Eclipse Scout runtime
101 lines • 4.66 kB
TypeScript
/// <reference types="jquery" />
import { EnumObject, HAlign, Key, KeyStrokeFirePolicy, KeyStrokeModel, ScoutKeyboardEvent, Widget } from '../index';
export declare class KeyStroke implements KeyStrokeModel {
field?: Widget;
/** keys which this keystroke is bound to. Typically, this is a single key, but may be multiple keys if handling the same action (e.g. ENTER and SPACE on a button). */
which: number[];
ctrl: boolean;
inheritAccessibility: boolean;
alt: boolean;
shift: boolean;
preventDefault: boolean;
stopPropagation: boolean;
stopImmediatePropagation: boolean;
keyStrokeMode: KeyStrokeMode;
/** whether the handle method is called multiple times while a key is pressed */
repeatable: boolean;
keyStrokeFirePolicy: KeyStrokeFirePolicy;
enabledByFilter: boolean;
/** Hints to control rendering of the key(s). */
renderingHints: KeyStrokeRenderingHints;
/**
* Indicates whether to invoke 'acceptInput' on a currently focused value field prior handling the keystroke.
*/
invokeAcceptInputOnActiveValueField: boolean;
/**
* Indicates whether to prevent to invoke 'acceptInput' on a currently focused value field prior handling the keystroke,
* either triggered by previous property or by KeyStrokeContext
*/
preventInvokeAcceptInputOnActiveValueField: boolean;
/** internal flag to remember whether the handle method has been executed (reset on keyup) */
protected _handleExecuted: boolean;
constructor();
/**
* Parses the given keystroke name into the key parts like 'ctrl', 'shift', 'alt' and 'which'.
*/
parseAndSetKeyStroke(keyStrokeName: string): void;
/**
* Returns true if this event is handled by this keystroke, and if so sets the propagation flags accordingly.
*/
accept(event: ScoutKeyboardEvent): boolean;
/**
* Method invoked to handle the given keystroke event, and is only called if the event was accepted by 'KeyStroke.accept(event)'.
*/
handle(event: JQuery.KeyboardEventBase): void;
invokeHandle(event: JQuery.KeyboardEventBase): void;
/**
* Method invoked in the context of accepting a keystroke, and returns true if the keystroke is accessible to the user.
*/
protected _isEnabled(): boolean;
/**
* Method invoked in the context of accepting a keystroke, and returns true if the event matches this keystroke.
*/
protected _accept(event: ScoutKeyboardEvent): boolean;
/**
* Method invoked in the context of accepting a keystroke, and sets the propagation flags accordingly.
*/
protected _applyPropagationFlags(event: ScoutKeyboardEvent): void;
/**
* Returns the key(s) associated with this keystroke. Typically, this is a single key, but may be multiple if this keystroke is associated with multiple keys, e.g. ENTER and SPACE on a button.
*/
keys(): Key[];
/**
* Renders the visual representation of this keystroke, with the 'which' as given by the event.
*
* @returns $drawingArea on which the key was finally rendered.
*/
renderKeyBox($drawingArea: JQuery, event: ScoutKeyboardEvent): JQuery;
protected _renderKeyBox($parent: JQuery, keyCode: number): JQuery;
/**
* Method invoked after this keystroke was rendered, and is typically overwritten to reposition the visual representation.
*/
protected _postRenderKeyBox($drawingArea: JQuery, $keyBox?: JQuery): void;
/**
* Removes the visual representation of this keystroke.
*/
removeKeyBox($drawingArea: JQuery): void;
static Mode: {
readonly UP: "keyup";
readonly DOWN: "keydown";
};
/**
* Parses the given keystroke name into the key parts like 'ctrl', 'shift', 'alt' and 'which'.
*
* @see "org.eclipse.scout.rt.client.ui.action.keystroke.KeyStrokeNormalizer"
*/
static parseKeyStroke(keyStrokeName: string): KeyStrokeModel;
static acceptEvent(keyStroke: KeyStrokeModel, event: ScoutKeyboardEvent): boolean;
static acceptModifiers(keyStroke: KeyStrokeModel, event: ScoutKeyboardEvent): boolean;
protected static _acceptModifier(modifier: boolean, eventModifier: boolean): boolean;
}
export type KeyStrokeMode = EnumObject<typeof KeyStroke.Mode>;
export interface KeyStrokeRenderingHints {
render: boolean | (() => boolean);
gap?: number;
offset?: number;
hAlign?: HAlign;
text?: string;
$drawingArea: KeystrokeRenderAreaProvider;
}
export type KeystrokeRenderAreaProvider = ($drawingArea: JQuery, event: ScoutKeyboardEvent) => JQuery;
//# sourceMappingURL=KeyStroke.d.ts.map