Example usage for com.google.gwt.user.client EventPreview onEventPreview

List of usage examples for com.google.gwt.user.client EventPreview onEventPreview

Introduction

In this page you can find the example usage for com.google.gwt.user.client EventPreview onEventPreview.

Prototype

@Deprecated
boolean onEventPreview(Event event);

Source Link

Document

Called when a browser event occurs and this event preview is on top of the preview stack.

Usage

From source file:fr.fg.client.core.Tutorial.java

License:Open Source License

public boolean onEventPreview(Event event) {
    boolean validEvent = false;

    // Autorise les vnements sur le dialogue, et un certain
    // nombre de types d'vnements
    if (Client.getInstance().getDialogManager().getElement().isOrHasChild(event.getTarget()))
        validEvent = true;/*w  w w .java2 s . c  om*/

    if (event.getTypeInt() == Event.ONMOUSEOVER || event.getTypeInt() == Event.ONMOUSEOUT
            || event.getTypeInt() == Event.ONMOUSEMOVE || event.getTypeInt() == Event.ONMOUSEUP)
        validEvent = true;

    if (!validEvent) {
        switch (subLesson) {
        case SUB_LESSON_BEGIN_MOVE_MAP:
            // Bloque tous les vnements sauf ceux pour dplacer la vue
            switch (event.getTypeInt()) {
            case Event.ONMOUSEDOWN:
                if (DOM.isOrHasChild(Client.getInstance().getAreaContainer().getElement(),
                        DOM.eventGetTarget(event))
                        || DOM.isOrHasChild(Client.getInstance().getAreaContainer().getMap().getMiniMaps()
                                .get(0).getElement(), DOM.eventGetTarget(event))) {
                    validEvent = true;
                }
                break;
            case Event.ONCLICK:
                if (DOM.isOrHasChild(
                        Client.getInstance().getAreaContainer().getMap().getMiniMaps().get(0).getElement(),
                        DOM.eventGetTarget(event))) {
                    validEvent = true;
                }
                break;
            case Event.ONKEYUP:
            case Event.ONKEYDOWN:
                int keyCode = DOM.eventGetKeyCode(event);

                if (keyCode >= 32 && keyCode <= 40)
                    validEvent = true;
                break;
            }
            break;
        }
    }

    if (validEvent) {
        for (EventPreview hook : EventManager.getEventHooks())
            hook.onEventPreview(event);
    } else {
        event.cancelBubble(true);
        event.preventDefault();
    }

    return validEvent;
}

From source file:fr.fg.client.openjwt.core.EventManager.java

License:Open Source License

public boolean onEventPreview(Event event) {
    for (EventPreview hook : hooks)
        hook.onEventPreview(event);

    return true;/*w  w w.ja v a2  s  . c om*/
}