API Reference 0.3.24dart_web_toolkit_eventKeyPressEvent

KeyPressEvent class

Represents a native key press event.

class KeyPressEvent extends KeyCodeEvent {

 /**
  * The event type.
  */
 static DomEventType<KeyPressHandler> TYPE = new DomEventType<KeyPressHandler>(BrowserEvents.KEYPRESS, new KeyPressEvent());

 DomEventType<KeyPressHandler> getAssociatedType() {
   return TYPE;
 }

 KeyPressEvent();

 void dispatch(KeyPressHandler handler) {
   handler.onKeyPress(this);
 }

 /**
  * Gets the Unicode char code (code point) for this event.
  *
  * @return the Unicode char code
  */
 int getUnicodeCharCode() {
   return getKeyboardEvent().charCode;
 }
}

Extends

IEvent<H> > DwtEvent > DomEvent > KeyEvent > KeyCodeEvent > KeyPressEvent

Static Properties

DomEventType<KeyPressHandler> TYPE #

The event type.

static DomEventType<KeyPressHandler> TYPE = new DomEventType<KeyPressHandler>(BrowserEvents.KEYPRESS, new KeyPressEvent())

Constructors

new KeyPressEvent() #

Constructor.

docs inherited from IEvent<H>
KeyPressEvent();

Methods

void assertLive() #

inherited from DwtEvent

Asserts that the event still should be accessed. All events are considered to be "dead" after their original handler manager finishes firing them. An event can be revived by calling {@link GwtEvent#revive()}.

void assertLive() {
 assert (!_dead) ; //: "This event has already finished being processed by its original handler manager, so you can no longer access it";
}

void dispatch(KeyPressHandler handler) #

Implemented by subclasses to invoke their handlers in a type safe manner. Intended to be called by EventBus#fireEvent(Event) or EventBus#fireEventFromSource(Event, Object).

@param handler handler @see EventBus#dispatchEvent(Event, Object)

docs inherited from IEvent<H>
void dispatch(KeyPressHandler handler) {
 handler.onKeyPress(this);
}

DomEventType<KeyPressHandler> getAssociatedType() #

Returns the EventType used to register this event, allowing an EventBus to find handlers of the appropriate class.

@return the type

docs inherited from IEvent<H>
DomEventType<KeyPressHandler> getAssociatedType() {
 return TYPE;
}

KeyboardEvent getKeyboardEvent() #

inherited from KeyEvent

Cast native event to KeyboardEvent.

dart_html.KeyboardEvent getKeyboardEvent() {
 if (getNativeEvent() is dart_html.KeyboardEvent) {
   return getNativeEvent() as dart_html.KeyboardEvent;
 }
 throw new Exception("Native event is not subtype of KeyboardEvent");
}

Event getNativeEvent() #

inherited from DomEvent

Gets the underlying native event.

@return the native event

docs inherited from HasNativeEvent
dart_html.Event getNativeEvent() {
 assertLive();
 return _nativeEvent;
}

int getNativeKeyCode() #

inherited from KeyCodeEvent

Gets the native key code. These key codes are enumerated in the {@link KeyCodes} class.

@return the key code

int getNativeKeyCode() {
 return getKeyboardEvent().keyCode;
}

Element getRelativeElement() #

inherited from DomEvent

Gets the element relative to which event coordinates will be measured. If this element is <code>null</code>, event coordinates will be measured relative to the window's client area.

@return the event's relative element

dart_html.Element getRelativeElement() {
 assertLive();
 return _relativeElem;
}

Object getSource() #

inherited from DwtEvent

Returns the source for this event. The type and meaning of the source is arbitrary, and is most useful as a secondary key for handler registration. (See EventBus#addHandlerToSource, which allows a handler to register for events of a particular type, tied to a particular source.)

Note that the source is actually set at dispatch time, e.g. via EventBus#fireEventFromSource(Event, Object).

@return object representing the source of this event

docs inherited from IEvent<H>
Object getSource() {
 assertLive();
 return super.getSource();
}

int getUnicodeCharCode() #

Gets the Unicode char code (code point) for this event.

@return the Unicode char code

int getUnicodeCharCode() {
 return getKeyboardEvent().charCode;
}

bool isAltKeyDown() #

inherited from KeyEvent

Is the <code>alt</code> key down?

@return whether the alt key is down

bool isAltKeyDown() {
 return getKeyboardEvent().altKey;
}

bool isAnyModifierKeyDown() #

inherited from KeyEvent

Does this event have any modifier keys down? Specifically. is the control, meta, shift, or alt key currently pressed?

@return whether this event have any modifier key down

bool isAnyModifierKeyDown() {
 return isControlKeyDown() || isShiftKeyDown() || isMetaKeyDown() || isAltKeyDown();
}

bool isControlKeyDown() #

inherited from KeyEvent

Is the <code>control</code> key down?

@return whether the control key is down

bool isControlKeyDown() {
 return getKeyboardEvent().ctrlKey;
}

bool isDownArrow() #

inherited from KeyCodeEvent

Is this a key down arrow?

@return whether this is a down arrow key event

bool isDownArrow() {
 return getNativeKeyCode() == KeyCodes.KEY_DOWN;
}

bool isLeftArrow() #

inherited from KeyCodeEvent

Is this a left arrow?

@return whether this is a left arrow key event

bool isLeftArrow() {
 return getNativeKeyCode() == KeyCodes.KEY_LEFT;
}

bool isLive() #

inherited from DwtEvent

Is the event current live?

@return whether the event is live

bool isLive() {
 return !_dead;
}

bool isMetaKeyDown() #

inherited from KeyEvent

Is the <code>meta</code> key down?

@return whether the meta key is down

bool isMetaKeyDown() {
 return getKeyboardEvent().metaKey;
}

bool isRightArrow() #

inherited from KeyCodeEvent

Is this a right arrow?

@return whether this is a right arrow key event

bool isRightArrow() {
 return getNativeKeyCode() == KeyCodes.KEY_RIGHT;
}

bool isShiftKeyDown() #

inherited from KeyEvent

Is the <code>shift</code> key down?

@return whether the shift key is down

bool isShiftKeyDown() {
 return getKeyboardEvent().shiftKey;
}

bool isUpArrow() #

inherited from KeyCodeEvent

Is this a up arrow?

@return whether this is a right arrow key event

bool isUpArrow() {
 return getNativeKeyCode() == KeyCodes.KEY_UP;
}

void kill() #

inherited from DwtEvent

Kill the event. After the event has been killed, users cannot really on its values or functions being available.

void kill() {
 _dead = true;
 setSource(null);
}

void overrideSource(Object source) #

inherited from DwtEvent
void overrideSource(Object source) {
 super.setSource(source);
}

void preventDefault() #

inherited from DomEvent

Prevents the wrapped native event's default action.

void preventDefault() {
 assertLive();
 _nativeEvent.preventDefault();
}

void revive() #

inherited from DwtEvent

Revives the event. Used when recycling event instances.

void revive() {
 _dead = false;
 setSource(null);
}

void setSource(source) #

inherited from IEvent

Set the source that triggered this event. Intended to be called by the EventBus during dispatch.

@param source the source of this event. @see EventBus#fireEventFromSource(Event, Object) @see EventBus#setSourceOfEvent(Event, Object)

void setSource(dynamic source) {
 this._source = source;
}

void stopPropagation() #

inherited from DomEvent

Stops the propagation of the underlying native event.

void stopPropagation() {
 assertLive();
 _nativeEvent.stopPropagation();
}

String toString() #

inherited from IEvent

The toString() for abstract event is overridden to avoid accidently including class literals in the the compiled output. Use Event

toDebugString to get more information about the event.

String toString() {
 return "An event type";
}