0001: /*
0002: * Copyright 2005 Joe Walker
0003: *
0004: * Licensed under the Apache License, Version 2.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.apache.org/licenses/LICENSE-2.0
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016: package jsx3.gui;
0017:
0018: import org.directwebremoting.ScriptBuffer;
0019: import org.directwebremoting.proxy.ScriptProxy;
0020: import org.directwebremoting.proxy.io.Context;
0021:
0022: /**
0023: * Native browser event wrapper.
0024: * @author Joe Walker [joe at getahead dot org]
0025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
0026: */
0027: public class Event extends jsx3.lang.Object {
0028: /**
0029: * All reverse ajax proxies need context to work from
0030: * @param scriptProxy The place we are writing scripts to
0031: * @param context The script that got us to where we are now
0032: */
0033: public Event(Context context, String extension,
0034: ScriptProxy scriptProxy) {
0035: super (context, extension, scriptProxy);
0036: }
0037:
0038: /**
0039: * The browser native event type beforeunload.
0040: */
0041: public static final String BEFOREUNLOAD = "beforeunload";
0042:
0043: /**
0044: * The browser native event type blur.
0045: */
0046: public static final String BLUR = "blur";
0047:
0048: /**
0049: * The browser native event type change.
0050: */
0051: public static final String CHANGE = "change";
0052:
0053: /**
0054: * The browser native event type click.
0055: */
0056: public static final String CLICK = "click";
0057:
0058: /**
0059: * The browser native event type dblclick.
0060: */
0061: public static final String DOUBLECLICK = "dblclick";
0062:
0063: /**
0064: * The browser native event type error.
0065: */
0066: public static final String ERROR = "error";
0067:
0068: /**
0069: * The browser native event type focus.
0070: */
0071: public static final String FOCUS = "focus";
0072:
0073: /**
0074: * The browser native event type keydown.
0075: */
0076: public static final String KEYDOWN = "keydown";
0077:
0078: /**
0079: * The browser native event type keypress.
0080: */
0081: public static final String KEYPRESS = "keypress";
0082:
0083: /**
0084: * The browser native event type keyup.
0085: */
0086: public static final String KEYUP = "keyup";
0087:
0088: /**
0089: * The browser native event type load.
0090: */
0091: public static final String LOAD = "load";
0092:
0093: /**
0094: * The browser native event type mousedown.
0095: */
0096: public static final String MOUSEDOWN = "mousedown";
0097:
0098: /**
0099: * The browser native event type mousemove.
0100: */
0101: public static final String MOUSEMOVE = "mousemove";
0102:
0103: /**
0104: * The browser native event type mouseout.
0105: */
0106: public static final String MOUSEOUT = "mouseout";
0107:
0108: /**
0109: * The browser native event type mouseover.
0110: */
0111: public static final String MOUSEOVER = "mouseover";
0112:
0113: /**
0114: * The browser native event type mouseup.
0115: */
0116: public static final String MOUSEUP = "mouseup";
0117:
0118: /**
0119: * The browser native event type mousewheel.
0120: */
0121: public static final String MOUSEWHEEL = "mousewheel";
0122:
0123: /**
0124: * The browser native event type unload.
0125: */
0126: public static final String UNLOAD = "unload";
0127:
0128: /**
0129: * The browser native event type resize.
0130: */
0131: public static final String RESIZE = "resize";
0132:
0133: /**
0134: * The browser native key code for the Alt key.
0135: */
0136: public static final int KEY_ALT = 18;
0137:
0138: /**
0139: * The browser native key code for the down arrow key.
0140: */
0141: public static final int KEY_ARROW_DOWN = 40;
0142:
0143: /**
0144: * The browser native key code for the left arrow key.
0145: */
0146: public static final int KEY_ARROW_LEFT = 37;
0147:
0148: /**
0149: * The browser native key code for the right arrow key.
0150: */
0151: public static final int KEY_ARROW_RIGHT = 39;
0152:
0153: /**
0154: * The browser native key code for the up arrow key.
0155: */
0156: public static final int KEY_ARROW_UP = 38;
0157:
0158: /**
0159: * The browser native key code for the Backspace key.
0160: */
0161: public static final int KEY_BACKSPACE = 8;
0162:
0163: /**
0164: * The browser native key code for the Ctrl key.
0165: */
0166: public static final int KEY_CONTROL = 17;
0167:
0168: /**
0169: * The browser native key code for the Delete key.
0170: */
0171: public static final int KEY_DELETE = 46;
0172:
0173: /**
0174: * The browser native key code for the End key.
0175: */
0176: public static final int KEY_END = 35;
0177:
0178: /**
0179: * The browser native key code for the Enter key.
0180: */
0181: public static final int KEY_ENTER = 13;
0182:
0183: /**
0184: * The browser native key code for the Esc key.
0185: */
0186: public static final int KEY_ESCAPE = 27;
0187:
0188: /**
0189: * The browser native key code for the Home key.
0190: */
0191: public static final int KEY_HOME = 36;
0192:
0193: /**
0194: * The browser native key code for the Insert key.
0195: */
0196: public static final int KEY_INSERT = 45;
0197:
0198: /**
0199: * The browser native key code for the Meta key.
0200: */
0201: public static final int KEY_META = 224;
0202:
0203: /**
0204: * The browser native key code for the Page Down key.
0205: */
0206: public static final int KEY_PAGE_DOWN = 34;
0207:
0208: /**
0209: * The browser native key code for the Page Up key.
0210: */
0211: public static final int KEY_PAGE_UP = 33;
0212:
0213: /**
0214: * The browser native key code for the Shift key.
0215: */
0216: public static final int KEY_SHIFT = 16;
0217:
0218: /**
0219: * The browser native key code for the space bar key.
0220: */
0221: public static final int KEY_SPACE = 32;
0222:
0223: /**
0224: * The browser native key code for the Tab key.
0225: */
0226: public static final int KEY_TAB = 9;
0227:
0228: /**
0229: * The browser native key code for the 0 key.
0230: */
0231: public static final int KEY_0 = 48;
0232:
0233: /**
0234: * The browser native key code for the 9 key.
0235: */
0236: public static final int KEY_9 = 57;
0237:
0238: /**
0239: * The browser native key code for the A key.
0240: */
0241: public static final int KEY_A = 65;
0242:
0243: /**
0244: * The browser native key code for the Z key.
0245: */
0246: public static final int KEY_Z = 90;
0247:
0248: /**
0249: * The browser native key code for the number pad 0 key.
0250: */
0251: public static final int KEY_NP0 = 96;
0252:
0253: /**
0254: * The browser native key code for the number pad 9 key.
0255: */
0256: public static final int KEY_NP9 = 105;
0257:
0258: /**
0259: * The browser native key code for the number pad division (/) key.
0260: */
0261: public static final int KEY_NPDIV = 111;
0262:
0263: /**
0264: * The browser native key code for the number pad multiply (*) key.
0265: */
0266: public static final int KEY_NPMUL = 106;
0267:
0268: /**
0269: * The browser native key code for the number pad subtract (-) key.
0270: */
0271: public static final int KEY_NPSUB = 109;
0272:
0273: /**
0274: * The browser native key code for the number pad addition (+) key.
0275: */
0276: public static final int KEY_NPADD = 107;
0277:
0278: /**
0279: * The browser native key code for the number pad decimal (.) key.
0280: */
0281: public static final int KEY_NPDEC = 110;
0282:
0283: /**
0284: * The browser native key code for the F1 key.
0285: */
0286: public static final int KEY_F1 = 112;
0287:
0288: /**
0289: * The browser native key code for the F15 key.
0290: */
0291: public static final int KEY_F15 = 126;
0292:
0293: /**
0294: * Subscribes an event handler to events of type strEventId that bubble all the way up to the browser window.
0295: * @param strEventId the event type, e.g. <code>jsx3.gui.Event.CLICK</code>.
0296: * @param objHandler
0297: * @param objFunction
0298: */
0299: public void subscribe(String strEventId,
0300: java.lang.Object objHandler, java.lang.Object objFunction) {
0301: ScriptBuffer script = new ScriptBuffer();
0302: script.appendCall(getContextPath() + "subscribe", strEventId,
0303: objHandler, objFunction);
0304: getScriptProxy().addScript(script);
0305: }
0306:
0307: /**
0308: * Unsubscribes an event handler from events of type strEventId that bubble all the way up to the browser window.
0309: * @param strEventId the event type, e.g. <code>jsx3.gui.Event.CLICK</code>.
0310: * @param objHandler
0311: */
0312: public void unsubscribe(String strEventId,
0313: java.lang.Object objHandler) {
0314: ScriptBuffer script = new ScriptBuffer();
0315: script.appendCall(getContextPath() + "unsubscribe", strEventId,
0316: objHandler);
0317: getScriptProxy().addScript(script);
0318: }
0319:
0320: /**
0321: * Unsubscribes all event handlers from a events of type strEventId that bubble all the way up to the browser window.
0322: * @param strEventId the event type, e.g. <code>jsx3.gui.Event.CLICK</code>.
0323: */
0324: public void unsubscribeAll(String strEventId) {
0325: ScriptBuffer script = new ScriptBuffer();
0326: script.appendCall(getContextPath() + "unsubscribeAll",
0327: strEventId);
0328: getScriptProxy().addScript(script);
0329: }
0330:
0331: /**
0332: * Returns the type of event, e.g. mousedown, click, etc.
0333: * @param callback event type
0334: */
0335: @SuppressWarnings("unchecked")
0336: public void getType(
0337: org.directwebremoting.proxy.Callback<String> callback) {
0338: ScriptBuffer script = new ScriptBuffer();
0339: String callbackPrefix = "";
0340:
0341: if (callback != null) {
0342: callbackPrefix = "var reply = ";
0343: }
0344:
0345: script
0346: .appendCall(callbackPrefix + getContextPath()
0347: + "getType");
0348:
0349: if (callback != null) {
0350: String key = org.directwebremoting.extend.CallbackHelper
0351: .saveCallback(callback, String.class);
0352: script
0353: .appendCall("__System.activateCallback", key,
0354: "reply");
0355: }
0356:
0357: getScriptProxy().addScript(script);
0358: }
0359:
0360: /**
0361: * Returns handle to the HTML element acted upon (click, mousedown, etc).
0362: * @param callback HTML object
0363: */
0364: @SuppressWarnings("unchecked")
0365: public void srcElement(
0366: org.directwebremoting.proxy.Callback<String> callback) {
0367: ScriptBuffer script = new ScriptBuffer();
0368: String callbackPrefix = "";
0369:
0370: if (callback != null) {
0371: callbackPrefix = "var reply = ";
0372: }
0373:
0374: script.appendCall(callbackPrefix + getContextPath()
0375: + "srcElement");
0376:
0377: if (callback != null) {
0378: String key = org.directwebremoting.extend.CallbackHelper
0379: .saveCallback(callback, String.class);
0380: script
0381: .appendCall("__System.activateCallback", key,
0382: "reply");
0383: }
0384:
0385: getScriptProxy().addScript(script);
0386: }
0387:
0388: /**
0389: * Returns handle to the HTML element that was moused over (onmouseover).
0390: * @param callback HTML object
0391: */
0392: @SuppressWarnings("unchecked")
0393: public void toElement(
0394: org.directwebremoting.proxy.Callback<String> callback) {
0395: ScriptBuffer script = new ScriptBuffer();
0396: String callbackPrefix = "";
0397:
0398: if (callback != null) {
0399: callbackPrefix = "var reply = ";
0400: }
0401:
0402: script.appendCall(callbackPrefix + getContextPath()
0403: + "toElement");
0404:
0405: if (callback != null) {
0406: String key = org.directwebremoting.extend.CallbackHelper
0407: .saveCallback(callback, String.class);
0408: script
0409: .appendCall("__System.activateCallback", key,
0410: "reply");
0411: }
0412:
0413: getScriptProxy().addScript(script);
0414: }
0415:
0416: /**
0417: * Returns handle to the HTML element that was moused away from (onmouseout).
0418: * @param callback HTML object
0419: */
0420: @SuppressWarnings("unchecked")
0421: public void fromElement(
0422: org.directwebremoting.proxy.Callback<String> callback) {
0423: ScriptBuffer script = new ScriptBuffer();
0424: String callbackPrefix = "";
0425:
0426: if (callback != null) {
0427: callbackPrefix = "var reply = ";
0428: }
0429:
0430: script.appendCall(callbackPrefix + getContextPath()
0431: + "fromElement");
0432:
0433: if (callback != null) {
0434: String key = org.directwebremoting.extend.CallbackHelper
0435: .saveCallback(callback, String.class);
0436: script
0437: .appendCall("__System.activateCallback", key,
0438: "reply");
0439: }
0440:
0441: getScriptProxy().addScript(script);
0442: }
0443:
0444: /**
0445: * Returns integer representing the key code of the key just pressed/keyed-down.
0446: * @param callback keycode
0447: */
0448: @SuppressWarnings("unchecked")
0449: public void keyCode(
0450: org.directwebremoting.proxy.Callback<Integer> callback) {
0451: ScriptBuffer script = new ScriptBuffer();
0452: String callbackPrefix = "";
0453:
0454: if (callback != null) {
0455: callbackPrefix = "var reply = ";
0456: }
0457:
0458: script
0459: .appendCall(callbackPrefix + getContextPath()
0460: + "keyCode");
0461:
0462: if (callback != null) {
0463: String key = org.directwebremoting.extend.CallbackHelper
0464: .saveCallback(callback, Integer.class);
0465: script
0466: .appendCall("__System.activateCallback", key,
0467: "reply");
0468: }
0469:
0470: getScriptProxy().addScript(script);
0471: }
0472:
0473: /**
0474: * Returns the clientX property for the event (where it occurred on-screen).
0475: * @param callback pixel position
0476: */
0477: @SuppressWarnings("unchecked")
0478: public void clientX(
0479: org.directwebremoting.proxy.Callback<Integer> callback) {
0480: ScriptBuffer script = new ScriptBuffer();
0481: String callbackPrefix = "";
0482:
0483: if (callback != null) {
0484: callbackPrefix = "var reply = ";
0485: }
0486:
0487: script
0488: .appendCall(callbackPrefix + getContextPath()
0489: + "clientX");
0490:
0491: if (callback != null) {
0492: String key = org.directwebremoting.extend.CallbackHelper
0493: .saveCallback(callback, Integer.class);
0494: script
0495: .appendCall("__System.activateCallback", key,
0496: "reply");
0497: }
0498:
0499: getScriptProxy().addScript(script);
0500: }
0501:
0502: /**
0503: * Returns the clientY property for the event (where it occurred on-screen).
0504: * @param callback pixel position
0505: */
0506: @SuppressWarnings("unchecked")
0507: public void clientY(
0508: org.directwebremoting.proxy.Callback<Integer> callback) {
0509: ScriptBuffer script = new ScriptBuffer();
0510: String callbackPrefix = "";
0511:
0512: if (callback != null) {
0513: callbackPrefix = "var reply = ";
0514: }
0515:
0516: script
0517: .appendCall(callbackPrefix + getContextPath()
0518: + "clientY");
0519:
0520: if (callback != null) {
0521: String key = org.directwebremoting.extend.CallbackHelper
0522: .saveCallback(callback, Integer.class);
0523: script
0524: .appendCall("__System.activateCallback", key,
0525: "reply");
0526: }
0527:
0528: getScriptProxy().addScript(script);
0529: }
0530:
0531: /**
0532: * Returns the actual position in the browser from the left edge for where the event occurred.
0533: * @param callback pixel position
0534: */
0535: @SuppressWarnings("unchecked")
0536: public void getTrueX(
0537: org.directwebremoting.proxy.Callback<Integer> callback) {
0538: ScriptBuffer script = new ScriptBuffer();
0539: String callbackPrefix = "";
0540:
0541: if (callback != null) {
0542: callbackPrefix = "var reply = ";
0543: }
0544:
0545: script.appendCall(callbackPrefix + getContextPath()
0546: + "getTrueX");
0547:
0548: if (callback != null) {
0549: String key = org.directwebremoting.extend.CallbackHelper
0550: .saveCallback(callback, Integer.class);
0551: script
0552: .appendCall("__System.activateCallback", key,
0553: "reply");
0554: }
0555:
0556: getScriptProxy().addScript(script);
0557: }
0558:
0559: /**
0560: * Returns the actual position in the browser from the top edge for where the event occurred.
0561: * @param callback pixel position
0562: */
0563: @SuppressWarnings("unchecked")
0564: public void getTrueY(
0565: org.directwebremoting.proxy.Callback<Integer> callback) {
0566: ScriptBuffer script = new ScriptBuffer();
0567: String callbackPrefix = "";
0568:
0569: if (callback != null) {
0570: callbackPrefix = "var reply = ";
0571: }
0572:
0573: script.appendCall(callbackPrefix + getContextPath()
0574: + "getTrueY");
0575:
0576: if (callback != null) {
0577: String key = org.directwebremoting.extend.CallbackHelper
0578: .saveCallback(callback, Integer.class);
0579: script
0580: .appendCall("__System.activateCallback", key,
0581: "reply");
0582: }
0583:
0584: getScriptProxy().addScript(script);
0585: }
0586:
0587: /**
0588: * Returns true if the shift key was pressed.
0589: */
0590: @SuppressWarnings("unchecked")
0591: public void shiftKey(
0592: org.directwebremoting.proxy.Callback<Boolean> callback) {
0593: ScriptBuffer script = new ScriptBuffer();
0594: String callbackPrefix = "";
0595:
0596: if (callback != null) {
0597: callbackPrefix = "var reply = ";
0598: }
0599:
0600: script.appendCall(callbackPrefix + getContextPath()
0601: + "shiftKey");
0602:
0603: if (callback != null) {
0604: String key = org.directwebremoting.extend.CallbackHelper
0605: .saveCallback(callback, Boolean.class);
0606: script
0607: .appendCall("__System.activateCallback", key,
0608: "reply");
0609: }
0610:
0611: getScriptProxy().addScript(script);
0612: }
0613:
0614: /**
0615: * Returns true the ctrl key was pressed.
0616: */
0617: @SuppressWarnings("unchecked")
0618: public void ctrlKey(
0619: org.directwebremoting.proxy.Callback<Boolean> callback) {
0620: ScriptBuffer script = new ScriptBuffer();
0621: String callbackPrefix = "";
0622:
0623: if (callback != null) {
0624: callbackPrefix = "var reply = ";
0625: }
0626:
0627: script
0628: .appendCall(callbackPrefix + getContextPath()
0629: + "ctrlKey");
0630:
0631: if (callback != null) {
0632: String key = org.directwebremoting.extend.CallbackHelper
0633: .saveCallback(callback, Boolean.class);
0634: script
0635: .appendCall("__System.activateCallback", key,
0636: "reply");
0637: }
0638:
0639: getScriptProxy().addScript(script);
0640: }
0641:
0642: /**
0643: * Returns true if the alt key was pressed.
0644: */
0645: @SuppressWarnings("unchecked")
0646: public void altKey(
0647: org.directwebremoting.proxy.Callback<Boolean> callback) {
0648: ScriptBuffer script = new ScriptBuffer();
0649: String callbackPrefix = "";
0650:
0651: if (callback != null) {
0652: callbackPrefix = "var reply = ";
0653: }
0654:
0655: script.appendCall(callbackPrefix + getContextPath() + "altKey");
0656:
0657: if (callback != null) {
0658: String key = org.directwebremoting.extend.CallbackHelper
0659: .saveCallback(callback, Boolean.class);
0660: script
0661: .appendCall("__System.activateCallback", key,
0662: "reply");
0663: }
0664:
0665: getScriptProxy().addScript(script);
0666: }
0667:
0668: /**
0669: * Returns true if the enter key was pressed.
0670: */
0671: @SuppressWarnings("unchecked")
0672: public void enterKey(
0673: org.directwebremoting.proxy.Callback<Boolean> callback) {
0674: ScriptBuffer script = new ScriptBuffer();
0675: String callbackPrefix = "";
0676:
0677: if (callback != null) {
0678: callbackPrefix = "var reply = ";
0679: }
0680:
0681: script.appendCall(callbackPrefix + getContextPath()
0682: + "enterKey");
0683:
0684: if (callback != null) {
0685: String key = org.directwebremoting.extend.CallbackHelper
0686: .saveCallback(callback, Boolean.class);
0687: script
0688: .appendCall("__System.activateCallback", key,
0689: "reply");
0690: }
0691:
0692: getScriptProxy().addScript(script);
0693: }
0694:
0695: /**
0696: * Returns true if the space bar was pressed.
0697: */
0698: @SuppressWarnings("unchecked")
0699: public void spaceKey(
0700: org.directwebremoting.proxy.Callback<Boolean> callback) {
0701: ScriptBuffer script = new ScriptBuffer();
0702: String callbackPrefix = "";
0703:
0704: if (callback != null) {
0705: callbackPrefix = "var reply = ";
0706: }
0707:
0708: script.appendCall(callbackPrefix + getContextPath()
0709: + "spaceKey");
0710:
0711: if (callback != null) {
0712: String key = org.directwebremoting.extend.CallbackHelper
0713: .saveCallback(callback, Boolean.class);
0714: script
0715: .appendCall("__System.activateCallback", key,
0716: "reply");
0717: }
0718:
0719: getScriptProxy().addScript(script);
0720: }
0721:
0722: /**
0723: * Returns true if the tab key was pressed.
0724: */
0725: @SuppressWarnings("unchecked")
0726: public void tabKey(
0727: org.directwebremoting.proxy.Callback<Boolean> callback) {
0728: ScriptBuffer script = new ScriptBuffer();
0729: String callbackPrefix = "";
0730:
0731: if (callback != null) {
0732: callbackPrefix = "var reply = ";
0733: }
0734:
0735: script.appendCall(callbackPrefix + getContextPath() + "tabKey");
0736:
0737: if (callback != null) {
0738: String key = org.directwebremoting.extend.CallbackHelper
0739: .saveCallback(callback, Boolean.class);
0740: script
0741: .appendCall("__System.activateCallback", key,
0742: "reply");
0743: }
0744:
0745: getScriptProxy().addScript(script);
0746: }
0747:
0748: /**
0749: * Returns true if the right-arrow key was pressed
0750: */
0751: @SuppressWarnings("unchecked")
0752: public void rightArrow(
0753: org.directwebremoting.proxy.Callback<Boolean> callback) {
0754: ScriptBuffer script = new ScriptBuffer();
0755: String callbackPrefix = "";
0756:
0757: if (callback != null) {
0758: callbackPrefix = "var reply = ";
0759: }
0760:
0761: script.appendCall(callbackPrefix + getContextPath()
0762: + "rightArrow");
0763:
0764: if (callback != null) {
0765: String key = org.directwebremoting.extend.CallbackHelper
0766: .saveCallback(callback, Boolean.class);
0767: script
0768: .appendCall("__System.activateCallback", key,
0769: "reply");
0770: }
0771:
0772: getScriptProxy().addScript(script);
0773: }
0774:
0775: /**
0776: * Returns true if the left-arrow key was pressed.
0777: */
0778: @SuppressWarnings("unchecked")
0779: public void leftArrow(
0780: org.directwebremoting.proxy.Callback<Boolean> callback) {
0781: ScriptBuffer script = new ScriptBuffer();
0782: String callbackPrefix = "";
0783:
0784: if (callback != null) {
0785: callbackPrefix = "var reply = ";
0786: }
0787:
0788: script.appendCall(callbackPrefix + getContextPath()
0789: + "leftArrow");
0790:
0791: if (callback != null) {
0792: String key = org.directwebremoting.extend.CallbackHelper
0793: .saveCallback(callback, Boolean.class);
0794: script
0795: .appendCall("__System.activateCallback", key,
0796: "reply");
0797: }
0798:
0799: getScriptProxy().addScript(script);
0800: }
0801:
0802: /**
0803: * Returns true if the up-arrow key was pressed.
0804: */
0805: @SuppressWarnings("unchecked")
0806: public void upArrow(
0807: org.directwebremoting.proxy.Callback<Boolean> callback) {
0808: ScriptBuffer script = new ScriptBuffer();
0809: String callbackPrefix = "";
0810:
0811: if (callback != null) {
0812: callbackPrefix = "var reply = ";
0813: }
0814:
0815: script
0816: .appendCall(callbackPrefix + getContextPath()
0817: + "upArrow");
0818:
0819: if (callback != null) {
0820: String key = org.directwebremoting.extend.CallbackHelper
0821: .saveCallback(callback, Boolean.class);
0822: script
0823: .appendCall("__System.activateCallback", key,
0824: "reply");
0825: }
0826:
0827: getScriptProxy().addScript(script);
0828: }
0829:
0830: /**
0831: * Returns true if the down-arrow key was pressed.
0832: */
0833: @SuppressWarnings("unchecked")
0834: public void downArrow(
0835: org.directwebremoting.proxy.Callback<Boolean> callback) {
0836: ScriptBuffer script = new ScriptBuffer();
0837: String callbackPrefix = "";
0838:
0839: if (callback != null) {
0840: callbackPrefix = "var reply = ";
0841: }
0842:
0843: script.appendCall(callbackPrefix + getContextPath()
0844: + "downArrow");
0845:
0846: if (callback != null) {
0847: String key = org.directwebremoting.extend.CallbackHelper
0848: .saveCallback(callback, Boolean.class);
0849: script
0850: .appendCall("__System.activateCallback", key,
0851: "reply");
0852: }
0853:
0854: getScriptProxy().addScript(script);
0855: }
0856:
0857: /**
0858: * Returns true if the delete key was pressed.
0859: */
0860: @SuppressWarnings("unchecked")
0861: public void deleteKey(
0862: org.directwebremoting.proxy.Callback<Boolean> callback) {
0863: ScriptBuffer script = new ScriptBuffer();
0864: String callbackPrefix = "";
0865:
0866: if (callback != null) {
0867: callbackPrefix = "var reply = ";
0868: }
0869:
0870: script.appendCall(callbackPrefix + getContextPath()
0871: + "deleteKey");
0872:
0873: if (callback != null) {
0874: String key = org.directwebremoting.extend.CallbackHelper
0875: .saveCallback(callback, Boolean.class);
0876: script
0877: .appendCall("__System.activateCallback", key,
0878: "reply");
0879: }
0880:
0881: getScriptProxy().addScript(script);
0882: }
0883:
0884: /**
0885: * Returns true if the backspace key was pressed.
0886: */
0887: @SuppressWarnings("unchecked")
0888: public void backspaceKey(
0889: org.directwebremoting.proxy.Callback<Boolean> callback) {
0890: ScriptBuffer script = new ScriptBuffer();
0891: String callbackPrefix = "";
0892:
0893: if (callback != null) {
0894: callbackPrefix = "var reply = ";
0895: }
0896:
0897: script.appendCall(callbackPrefix + getContextPath()
0898: + "backspaceKey");
0899:
0900: if (callback != null) {
0901: String key = org.directwebremoting.extend.CallbackHelper
0902: .saveCallback(callback, Boolean.class);
0903: script
0904: .appendCall("__System.activateCallback", key,
0905: "reply");
0906: }
0907:
0908: getScriptProxy().addScript(script);
0909: }
0910:
0911: /**
0912: * Returns true if the insert key was pressed.
0913: */
0914: @SuppressWarnings("unchecked")
0915: public void insertKey(
0916: org.directwebremoting.proxy.Callback<Boolean> callback) {
0917: ScriptBuffer script = new ScriptBuffer();
0918: String callbackPrefix = "";
0919:
0920: if (callback != null) {
0921: callbackPrefix = "var reply = ";
0922: }
0923:
0924: script.appendCall(callbackPrefix + getContextPath()
0925: + "insertKey");
0926:
0927: if (callback != null) {
0928: String key = org.directwebremoting.extend.CallbackHelper
0929: .saveCallback(callback, Boolean.class);
0930: script
0931: .appendCall("__System.activateCallback", key,
0932: "reply");
0933: }
0934:
0935: getScriptProxy().addScript(script);
0936: }
0937:
0938: /**
0939: * Returns true if the home key was pressed.
0940: */
0941: @SuppressWarnings("unchecked")
0942: public void homeKey(
0943: org.directwebremoting.proxy.Callback<Boolean> callback) {
0944: ScriptBuffer script = new ScriptBuffer();
0945: String callbackPrefix = "";
0946:
0947: if (callback != null) {
0948: callbackPrefix = "var reply = ";
0949: }
0950:
0951: script
0952: .appendCall(callbackPrefix + getContextPath()
0953: + "homeKey");
0954:
0955: if (callback != null) {
0956: String key = org.directwebremoting.extend.CallbackHelper
0957: .saveCallback(callback, Boolean.class);
0958: script
0959: .appendCall("__System.activateCallback", key,
0960: "reply");
0961: }
0962:
0963: getScriptProxy().addScript(script);
0964: }
0965:
0966: /**
0967: * Returns true if the end key was pressed.
0968: */
0969: @SuppressWarnings("unchecked")
0970: public void endKey(
0971: org.directwebremoting.proxy.Callback<Boolean> callback) {
0972: ScriptBuffer script = new ScriptBuffer();
0973: String callbackPrefix = "";
0974:
0975: if (callback != null) {
0976: callbackPrefix = "var reply = ";
0977: }
0978:
0979: script.appendCall(callbackPrefix + getContextPath() + "endKey");
0980:
0981: if (callback != null) {
0982: String key = org.directwebremoting.extend.CallbackHelper
0983: .saveCallback(callback, Boolean.class);
0984: script
0985: .appendCall("__System.activateCallback", key,
0986: "reply");
0987: }
0988:
0989: getScriptProxy().addScript(script);
0990: }
0991:
0992: /**
0993: * Returns true if the page-up key was pressed.
0994: */
0995: @SuppressWarnings("unchecked")
0996: public void pageUpKey(
0997: org.directwebremoting.proxy.Callback<Boolean> callback) {
0998: ScriptBuffer script = new ScriptBuffer();
0999: String callbackPrefix = "";
1000:
1001: if (callback != null) {
1002: callbackPrefix = "var reply = ";
1003: }
1004:
1005: script.appendCall(callbackPrefix + getContextPath()
1006: + "pageUpKey");
1007:
1008: if (callback != null) {
1009: String key = org.directwebremoting.extend.CallbackHelper
1010: .saveCallback(callback, Boolean.class);
1011: script
1012: .appendCall("__System.activateCallback", key,
1013: "reply");
1014: }
1015:
1016: getScriptProxy().addScript(script);
1017: }
1018:
1019: /**
1020: * Returns true if the page-down key was pressed.
1021: */
1022: @SuppressWarnings("unchecked")
1023: public void pageDownKey(
1024: org.directwebremoting.proxy.Callback<Boolean> callback) {
1025: ScriptBuffer script = new ScriptBuffer();
1026: String callbackPrefix = "";
1027:
1028: if (callback != null) {
1029: callbackPrefix = "var reply = ";
1030: }
1031:
1032: script.appendCall(callbackPrefix + getContextPath()
1033: + "pageDownKey");
1034:
1035: if (callback != null) {
1036: String key = org.directwebremoting.extend.CallbackHelper
1037: .saveCallback(callback, Boolean.class);
1038: script
1039: .appendCall("__System.activateCallback", key,
1040: "reply");
1041: }
1042:
1043: getScriptProxy().addScript(script);
1044: }
1045:
1046: /**
1047: * Returns true if the escape key was pressed.
1048: */
1049: @SuppressWarnings("unchecked")
1050: public void escapeKey(
1051: org.directwebremoting.proxy.Callback<Boolean> callback) {
1052: ScriptBuffer script = new ScriptBuffer();
1053: String callbackPrefix = "";
1054:
1055: if (callback != null) {
1056: callbackPrefix = "var reply = ";
1057: }
1058:
1059: script.appendCall(callbackPrefix + getContextPath()
1060: + "escapeKey");
1061:
1062: if (callback != null) {
1063: String key = org.directwebremoting.extend.CallbackHelper
1064: .saveCallback(callback, Boolean.class);
1065: script
1066: .appendCall("__System.activateCallback", key,
1067: "reply");
1068: }
1069:
1070: getScriptProxy().addScript(script);
1071: }
1072:
1073: /**
1074: * Cancels event bubbling for the event.
1075: */
1076: public void cancelBubble() {
1077: ScriptBuffer script = new ScriptBuffer();
1078: script.appendCall(getContextPath() + "cancelBubble");
1079: getScriptProxy().addScript(script);
1080: }
1081:
1082: /**
1083: * Cancels the return value for the event.
1084: */
1085: public void cancelReturn() {
1086: ScriptBuffer script = new ScriptBuffer();
1087: script.appendCall(getContextPath() + "cancelReturn");
1088: getScriptProxy().addScript(script);
1089: }
1090:
1091: /**
1092: * Cancels the key from firing by setting the keyCode to 0 (zero) for the event.
1093: */
1094: public void cancelKey() {
1095: ScriptBuffer script = new ScriptBuffer();
1096: script.appendCall(getContextPath() + "cancelKey");
1097: getScriptProxy().addScript(script);
1098: }
1099:
1100: /**
1101: * Returns true if the left-mouse-button was clicked.
1102: */
1103: @SuppressWarnings("unchecked")
1104: public void leftButton(
1105: org.directwebremoting.proxy.Callback<Boolean> callback) {
1106: ScriptBuffer script = new ScriptBuffer();
1107: String callbackPrefix = "";
1108:
1109: if (callback != null) {
1110: callbackPrefix = "var reply = ";
1111: }
1112:
1113: script.appendCall(callbackPrefix + getContextPath()
1114: + "leftButton");
1115:
1116: if (callback != null) {
1117: String key = org.directwebremoting.extend.CallbackHelper
1118: .saveCallback(callback, Boolean.class);
1119: script
1120: .appendCall("__System.activateCallback", key,
1121: "reply");
1122: }
1123:
1124: getScriptProxy().addScript(script);
1125: }
1126:
1127: /**
1128: * Returns true if the right-mouse-button was clicked.
1129: */
1130: @SuppressWarnings("unchecked")
1131: public void rightButton(
1132: org.directwebremoting.proxy.Callback<Boolean> callback) {
1133: ScriptBuffer script = new ScriptBuffer();
1134: String callbackPrefix = "";
1135:
1136: if (callback != null) {
1137: callbackPrefix = "var reply = ";
1138: }
1139:
1140: script.appendCall(callbackPrefix + getContextPath()
1141: + "rightButton");
1142:
1143: if (callback != null) {
1144: String key = org.directwebremoting.extend.CallbackHelper
1145: .saveCallback(callback, Boolean.class);
1146: script
1147: .appendCall("__System.activateCallback", key,
1148: "reply");
1149: }
1150:
1151: getScriptProxy().addScript(script);
1152: }
1153:
1154: /**
1155: * Returns integer designating the mouse button clicked/moused-down/moused-up; 1 (left), 2 (right), and as supported.
1156: */
1157: @SuppressWarnings("unchecked")
1158: public void button(
1159: org.directwebremoting.proxy.Callback<Integer> callback) {
1160: ScriptBuffer script = new ScriptBuffer();
1161: String callbackPrefix = "";
1162:
1163: if (callback != null) {
1164: callbackPrefix = "var reply = ";
1165: }
1166:
1167: script.appendCall(callbackPrefix + getContextPath() + "button");
1168:
1169: if (callback != null) {
1170: String key = org.directwebremoting.extend.CallbackHelper
1171: .saveCallback(callback, Integer.class);
1172: script
1173: .appendCall("__System.activateCallback", key,
1174: "reply");
1175: }
1176:
1177: getScriptProxy().addScript(script);
1178: }
1179:
1180: /**
1181: * Sets the the return value for the event.
1182: * @param strReturn string message to set on the returnValue for the event
1183: */
1184: public void setReturn(String strReturn) {
1185: ScriptBuffer script = new ScriptBuffer();
1186: script.appendCall(getContextPath() + "setReturn", strReturn);
1187: getScriptProxy().addScript(script);
1188: }
1189:
1190: /**
1191: * Whether one of the four arrow keys was pressed.
1192: */
1193: @SuppressWarnings("unchecked")
1194: public void isArrowKey(
1195: org.directwebremoting.proxy.Callback<Boolean> callback) {
1196: ScriptBuffer script = new ScriptBuffer();
1197: String callbackPrefix = "";
1198:
1199: if (callback != null) {
1200: callbackPrefix = "var reply = ";
1201: }
1202:
1203: script.appendCall(callbackPrefix + getContextPath()
1204: + "isArrowKey");
1205:
1206: if (callback != null) {
1207: String key = org.directwebremoting.extend.CallbackHelper
1208: .saveCallback(callback, Boolean.class);
1209: script
1210: .appendCall("__System.activateCallback", key,
1211: "reply");
1212: }
1213:
1214: getScriptProxy().addScript(script);
1215: }
1216:
1217: /**
1218: * Whether one of the 15 function keys was pressed.
1219: */
1220: @SuppressWarnings("unchecked")
1221: public void isFunctionKey(
1222: org.directwebremoting.proxy.Callback<Boolean> callback) {
1223: ScriptBuffer script = new ScriptBuffer();
1224: String callbackPrefix = "";
1225:
1226: if (callback != null) {
1227: callbackPrefix = "var reply = ";
1228: }
1229:
1230: script.appendCall(callbackPrefix + getContextPath()
1231: + "isFunctionKey");
1232:
1233: if (callback != null) {
1234: String key = org.directwebremoting.extend.CallbackHelper
1235: .saveCallback(callback, Boolean.class);
1236: script
1237: .appendCall("__System.activateCallback", key,
1238: "reply");
1239: }
1240:
1241: getScriptProxy().addScript(script);
1242: }
1243:
1244: }
|