1 21 package org.lobobrowser.html.js; 22 23 import org.w3c.dom.html2.*; 24 import java.awt.event.*; 25 import org.lobobrowser.js.*; 26 27 public class Event extends AbstractScriptableDelegate { 28 private boolean cancelBubble; 29 private HTMLElement fromElement, toElement; 30 private int leafX, leafY; 31 private boolean returnValue; 32 private HTMLElement srcElement; 33 private String type; 34 private final java.awt.event.InputEvent inputEvent; 35 36 public Event(String type, HTMLElement srcElement, java.awt.event.InputEvent mouseEvent, int leafX, int leafY) { 37 this.type = type; 38 this.srcElement = srcElement; 39 this.leafX = leafX; 40 this.leafY = leafY; 41 this.inputEvent = mouseEvent; 42 } 43 44 public Event(String type, HTMLElement srcElement, java.awt.event.KeyEvent keyEvent) { 45 this.type = type; 46 this.srcElement = srcElement; 47 this.inputEvent = keyEvent; 48 } 49 50 public boolean getAltKey() { 51 return this.inputEvent.isAltDown(); 52 } 53 54 public boolean getShiftKey() { 55 return this.inputEvent.isShiftDown(); 56 } 57 58 public boolean getCtrlKey() { 59 return this.inputEvent.isControlDown(); 60 } 61 62 public int getButton() { 63 InputEvent ie = this.inputEvent; 64 if(ie instanceof MouseEvent) { 65 return ((MouseEvent) ie).getButton(); 66 } 67 else { 68 return 0; 69 } 70 } 71 72 public boolean isCancelBubble() { 73 return cancelBubble; 74 } 75 76 public void setCancelBubble(boolean cancelBubble) { 77 this.cancelBubble = cancelBubble; 78 } 79 80 public String getType() { 81 return type; 82 } 83 84 public void setType(String type) { 85 this.type = type; 86 } 87 88 public int getClientX() { 89 InputEvent ie = this.inputEvent; 90 if(ie instanceof MouseEvent) { 91 return ((MouseEvent) ie).getX(); 92 } 93 else { 94 return 0; 95 } 96 } 97 98 public int getClientY() { 99 InputEvent ie = this.inputEvent; 100 if(ie instanceof MouseEvent) { 101 return ((MouseEvent) ie).getY(); 102 } 103 else { 104 return 0; 105 } 106 } 107 108 public int getKeyCode() { 109 InputEvent ie = this.inputEvent; 110 if(ie instanceof KeyEvent) { 111 return ((KeyEvent) ie).getKeyCode(); 112 } 113 else { 114 return 0; 115 } 116 } 117 118 132 public boolean isReturnValue() { 133 return returnValue; 134 } 135 136 public void setReturnValue(boolean returnValue) { 137 this.returnValue = returnValue; 138 } 139 140 public HTMLElement getSrcElement() { 141 return srcElement; 142 } 143 144 public void setSrcElement(HTMLElement srcElement) { 145 this.srcElement = srcElement; 146 } 147 148 public HTMLElement getFromElement() { 149 return fromElement; 150 } 151 152 public void setFromElement(HTMLElement fromElement) { 153 this.fromElement = fromElement; 154 } 155 156 public HTMLElement getToElement() { 157 return toElement; 158 } 159 160 public void setToElement(HTMLElement toElement) { 161 this.toElement = toElement; 162 } 163 164 public int getLeafX() { 165 return leafX; 166 } 167 168 public void setLeafX(int leafX) { 169 this.leafX = leafX; 170 } 171 172 public int getLeafY() { 173 return leafY; 174 } 175 176 public void setLeafY(int leafY) { 177 this.leafY = leafY; 178 } 179 } 180 | Popular Tags |