lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
59 lines (58 loc) • 2.89 kB
TypeScript
import { CompoundClickHelper } from "./CompoundClickHelper.js";
import { GenericClickHelper } from "./GenericClickHelper.js";
import { FocusType } from "../core/FocusType.js";
import { ClickHelper } from "./ClickHelper.js";
import type { Widget } from "../widgets/Widget.js";
import type { TricklingEvent } from "../events/TricklingEvent.js";
import type { Root } from "../core/Root.js";
import type { Bounds } from "./Bounds.js";
/**
* A {@link CompoundClickHelper} specialised for {@link Button}-like widgets.
* Handles pointer clicks and enter key-presses if the widget has a keyboard
* focus.
*
* {@link GenericClickHelper} methods are still available, however, calls to the
* new methods provided by this class are preferrable; mostly they implement
* {@link Widget} methods.
*
* @category Helper
*/
export declare class ButtonClickHelper extends CompoundClickHelper {
/** The helper for handling pointer clicks */
protected pointerClickHelper: ClickHelper;
/** The helper for handling enter key presses */
protected keyboardClickHelper: GenericClickHelper;
/** The widget that will be auto-scrolled when keyboard focused */
private widget;
private pointerFocused;
constructor(widget: Widget);
/**
* Handle focus grabbing from a {@link FocusEvent}. If keyboard focus is
* gained, then the button is hovered via the
* {@link ButtonClickHelper#keyboardClickHelper} click helper
*
* @param focusType - The focus type from the {@link FocusEvent}
* @returns Returns true if the focus type was the keyboard focus (and therefore the button probably needs to be re-painted)
*/
onFocusGrabbed(focusType: FocusType): boolean;
/**
* Handle focus dropping from a {@link BlurEvent}. If keyboard focus is
* dropped, then the button is released via the
* {@link ButtonClickHelper#keyboardClickHelper} click helper
*
* @param focusType - The focus type from the {@link BlurEvent}
* @returns Returns true if the focus type was the keyboard focus (and therefore the button probably needs to be re-painted)
*/
onFocusDropped(focusType: FocusType): boolean;
/**
* Handle event from {@link Widget#handleEvent}. Does most of the button
* logic.
*
* @param event - The event from {@link Widget#handleEvent}
* @param root - The root from {@link Widget#handleEvent}
* @param enabled - Is the button being clicked enabled? If not, then the click state will remain unchanged, but the event will be captured
* @param bounds - The bounding box to be used for detecting pointer clicks
* @returns Returns a 2-tuple containing, respective, whether a click occurred, and whether the event should be captured
*/
handleEvent(event: TricklingEvent, root: Root, enabled: boolean, bounds: Bounds): [wasClick: boolean, capture: boolean];
}