/** * @module seng-event */ import EventPhase from './EventPhase'; import CallListenerResult from './CallListenerResult'; import { EventHandlerForEvent } from './EventTypings'; import EventDispatcher from './EventDispatcher'; /** * Abstract base class for all events that can be dispatched through [[EventDispatcher]]. This class * should not be instantiated but extended by a specific event class. * * @see [[createEventClass]] */ declare abstract class AbstractEvent { /** * The type of the event. Event listeners will only be called if their eventType match this type. */ type: string; /** * If true, the event will also go through a bubbling phase. See [[EventDispatcher.dispatchEvent]] * for more information on the event phases. */ bubbles: boolean; /** * Indicates if [[preventDefault]] can be called on this event. This will prevent the 'default * action' of the event from being executed. It is up to the [[EventDispatcher]] instance that dispatches the * event to stop the default action from executing when the [[EventDispatcher.dispatchEvent|dispatchEvent]] * method returns `false` */ cancelable: boolean; /** * Will be updated by [[EventDispatcher]] during the dispatch of an event to the target that * listeners are currently being called on. After completion of an event dispatch this value * will be reset to `null`. */ currentTarget: EventDispatcher | null; /** * Will be updated by [[EventDispatcher]] when [[EventDispatcher.dispatchEvent|dispatchEvent]] is * called with this event. The value will be set to the EventDispatcher instance that dispatched * the event. */ target: EventDispatcher | null; /** * The current event phase of this event. During event dispatch, this value will be either * [[EventPhase.CAPTURING_PHASE|CAPTURING_PHASE]], [[EventPhase.AT_TARGET|AT_TARGET]] or * [[EventPhase.BUBBLING_PHASE|BUBBLING_PHASE]]. If this event is not currently being dispatched this will be * set to [[EventPhase.NONE|NONE]]. */ eventPhase: EventPhase; /** * Indicates the time this event is dispatched in the number of milliseconds elapsed since * _1 January 1970 00:00:00 UTC_. This value will only be set if the setTimestamp parameter in the constructor * is set to `true`. Otherwise, this value will be _0_. */ timeStamp: number; /** * `true` if [[cancelable]] is true and [[preventDefault]] has been called on this event. */ defaultPrevented: boolean; /** * Creates a new AbstractEvent instance. * @param type The type of the event. Event listeners will only be called if their eventType match this type. * @param bubbles If true, the event will also go through a bubbling phase. See [[EventDispatcher.dispatchEvent]] * for more information on the event phases. * @param cancelable Indicates if [[preventDefault]] can be called on this event. This will prevent the 'default * action' of the event from being executed. It is up to the [[EventDispatcher]] instance that dispatches the * event to stop the default action from executing when the [[EventDispatcher.dispatchEvent|dispatchEvent]] * method returns `false` * @param setTimeStamp If true, will set the [[timeStamp]] property of this event to the current time whenever * this event is dispatched. */ constructor(type: string, bubbles?: boolean, cancelable?: boolean, setTimeStamp?: boolean); /** * When called during the dispatch of an event, will prevent any targets further in the event chain * from being processed. All listeners on the current target will still be executed. * @see [[EventDispatcher.dispatchEvent]] */ stopPropagation(): void; /** * When called during the dispatch of an event, will prevent any other event listener from being * called for this event. * @see [[EventDispatcher.dispatchEvent]] */ stopImmediatePropagation(): void; /** * May only be called when the [[cancelable]] property of an event is set to `true`. Indicates to the * instance that dispatched the event that the default action for the event should not be executed. */ preventDefault(): void; /** * Calls the given event handler, and returns an enum value that indicates if [[stopPropagation]] or * [[stopImmediatePropagation]] have been called on this event during the execution of that handler. * @param handler The event handler to execute * @returns An enum value, see [[CallListenerResult]] */ callListener(handler: EventHandlerForEvent): CallListenerResult; /** * Should be implemented by child classes and return a copy of the event */ abstract clone(): AbstractEvent; } export default AbstractEvent;