01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.core;
09:
10: import com.google.gwt.user.client.Element;
11: import com.gwtext.client.core.event.TextResizeListener;
12:
13: /**
14: * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and
15: * provides several useful events directly.
16: */
17: public class EventManager {
18:
19: /**
20: * Appends an event handler to an element.
21: *
22: * @param element the element
23: * @param eventName the event name
24: * @param cb the callback to execute on event
25: * @param config the listener config
26: */
27: public static native void addListener(Element element,
28: String eventName, EventCallback cb, ListenerConfig config) /*-{
29: $wnd.Ext.EventManager.addListener(element, eventName, function(event) {
30: var e = (event === undefined || event == null) ? null : @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
31: cb.@com.gwtext.client.core.EventCallback::execute(Lcom/gwtext/client/core/EventObject;)(e);
32: },
33: null,
34: config.@com.gwtext.client.core.JsObject::jsObj
35: );
36: }-*/;
37:
38: /**
39: * Fires when the document is ready (before onload and before images are loaded).
40: * Can alternatively use the GWT entry point mechanism.
41: *
42: * @param cb callback to execute
43: */
44: public static native void onDocumentReady(Function cb) /*-{
45: $wnd.Ext.EventManager.onDocumentReady(function() {
46: cb.@com.gwtext.client.core.Function::execute()();
47: });
48: }-*/;
49:
50: // excluded onWindowResize
51: // Use com.google.gwt.user.client.WindowResizeListener instead
52:
53: public static native void addTextResizeListener(
54: TextResizeListener listener) /*-{
55: $wnd.Ext.EventManager.onTextResize(
56: function(oldSize, newSize) {
57: listener.@com.gwtext.client.core.event.TextResizeListener::onTextResize(II)(oldSize, newSize);
58: });
59: }-*/;
60: }
|