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:
09: package com.gwtext.client.util;
10:
11: import com.google.gwt.core.client.JavaScriptObject;
12: import com.gwtext.client.core.JsObject;
13: import com.gwtext.client.util.event.ClickRepeaterListener;
14:
15: /**
16: * A wrapper class which can be applied to any element. Fires a "click" event while the mouse is pressed.
17: * The interval between firings may be specified in the config but defaults to 10 milliseconds. Optionally,
18: * a CSS class may be applied to the element during the time it is pressed.
19: */
20: public class ClickRepeater extends JsObject {
21:
22: /**
23: * Create a new ClickRepeater.
24: *
25: * @param config ClickRepeater configuration
26: */
27: public ClickRepeater(ClickRepeaterConfig config) {
28: jsObj = create(config.getJsObj());
29: }
30:
31: private native JavaScriptObject create(JavaScriptObject config) /*-{
32: return new $wnd.Ext.util.ClickRepeater(config);
33: }-*/;
34:
35: /**
36: * Add a ClickRepeater listener.
37: *
38: * @param listener the listener
39: */
40: public native void addListener(ClickRepeaterListener listener)/*-{
41: var cr = this.@com.gwtext.client.core.JsObject::getJsObj()();
42: var crJ = this;
43:
44: cr.addListener('click',
45: function(source) {
46: listener.@com.gwtext.client.util.event.ClickRepeaterListener::onClick(Lcom/gwtext/client/util/ClickRepeater;)(crJ);
47: }
48: );
49:
50: cr.addListener('mousedown',
51: function(source) {
52: listener.@com.gwtext.client.util.event.ClickRepeaterListener::onMouseDown(Lcom/gwtext/client/util/ClickRepeater;)(crJ);
53: }
54: );
55:
56: cr.addListener('mouseup',
57: function(source) {
58: listener.@com.gwtext.client.util.event.ClickRepeaterListener::onMouseUp(Lcom/gwtext/client/util/ClickRepeater;)(crJ);
59: }
60: );
61: }-*/;
62: }
|