Changeset 569
- Timestamp:
- 12/04/13 15:34:41 (11 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/widgets/JfxBrowser.java
r568 r569 25 25 import org.expeditee.gui.DisplayIO; 26 26 import org.expeditee.gui.FrameMouseActions; 27 import org.expeditee.gui.FrameUtils; 27 28 import org.expeditee.gui.FreeItems; 28 29 import org.expeditee.gui.MessageBay; … … 47 48 48 49 private WebBrowserPanel _browser; 50 51 /** 52 * ID of the mouse button that is currently pressed. Uses {@link MouseEvent} constants 53 */ 54 private int buttonDownId; 49 55 50 56 private static class WebBrowserPanel extends JPanel implements ComponentListener { … … 129 135 130 136 @Override 131 public void keyReleased(KeyEvent arg0) { 132 } 133 134 @Override 135 public void keyPressed(KeyEvent arg0) { 137 public void keyReleased(KeyEvent arg0) { // TODO: remove if not used 138 } 139 140 @Override 141 public void keyPressed(KeyEvent arg0) { // TODO: remove if not used 136 142 } 137 143 }); … … 151 157 urlField.getLocationOnScreen().y + urlField.modelToView(urlField.getCaretPosition()).y - org.expeditee.gui.Browser._theBrowser.getOrigin().y); 152 158 153 } catch (BadLocationException e) { 154 } 159 } catch (BadLocationException e) {} 155 160 } else { 156 161 // Otherwise, move the caret to the cursor location … … 216 221 public void mousePressed(MouseEvent arg0) { 217 222 buttonDownId = arg0.getButton(); 223 218 224 } 219 225 … … 313 319 } 314 320 })); 315 321 322 // Captures mouse click events on webview to enable expeditee like behavior for JavaFX browser. 323 JavaFX.NodeSetOnMouseClicked.invoke(this.webview, java.lang.reflect.Proxy.newProxyInstance( 324 JavaFX.EventHandler.getClassLoader(), new java.lang.Class[] { JavaFX.EventHandler }, 325 new java.lang.reflect.InvocationHandler() { 326 @Override 327 public Object invoke(Object proxy, java.lang.reflect.Method method, Object[] args) 328 throws java.lang.Throwable { 329 330 if(method.getName().equals("handle")) { 331 // Gets button clicked enum values 332 Object[] buttonEnum = JavaFX.MouseButton.getEnumConstants(); 333 334 if(JavaFX.MouseEventGetButton.invoke(args[0]).equals(buttonEnum[1])) /* Left Mouse Button */ { 335 /*$#remove*/System.err.println("Left Button Clicked"); 336 } else if(JavaFX.MouseEventGetButton.invoke(args[0]).equals(buttonEnum[2])) /* Middle Mouse Button */ { 337 /*$#remove*/System.err.println("Middle Button Clicked"); 338 } else if(JavaFX.MouseEventGetButton.invoke(args[0]).equals(buttonEnum[3])) /* Right Mouse Button */ { 339 /*$#remove*/System.err.println("Right Button Clicked"); 340 // Gets text currently selected in webview 341 String selection = (String) JavaFX.WebEngineExecuteScript.invoke(JavaFX.WebViewGetEngine.invoke(webview), "window.getSelection().toString()"); 342 343 // Copy text and attach to cursor 344 Text t = new Text(selection); 345 t.setParent(DisplayIO.getCurrentFrame()); 346 t.setXY(FrameMouseActions.getX(), FrameMouseActions.getY()); 347 FrameMouseActions.pickup(t); 348 } 349 } 350 351 return null; 352 } 353 })); 354 355 // Disables JavaFX webview's right click menu 356 JavaFX.WebViewSetContextMenuEnabled.invoke(this.webview, false); 357 316 358 // webEngine.getLoadWorker().stateProperty().addListener( 317 359 // new ChangeListener<State>() { -
trunk/src/org/expeditee/reflection/JavaFX.java
r566 r569 25 25 public static Method WebViewSetPrefSize; 26 26 public static Method WebViewGetEngine; 27 public static Method WebViewSetContextMenuEnabled; 27 28 28 29 public static Class WebEngine; … … 49 50 public static Class State; 50 51 public static List<Object> StateConstants; 52 53 public static Class EventHandler; 54 55 public static Class Node; 56 public static Method NodeSetOnMouseClicked; 57 58 public static Class MouseEvent; 59 public static Method MouseEventGetButton; 60 61 public static Class MouseButton; 51 62 52 63 public static Class JSObject; … … 86 97 WebViewSetPrefSize = WebView.getMethod("setPrefSize", double.class, double.class); 87 98 WebViewGetEngine = WebView.getMethod("getEngine"); 99 WebViewSetContextMenuEnabled = WebView.getMethod("setContextMenuEnabled", boolean.class); 88 100 89 101 WebEngine = classLoader.loadClass("javafx.scene.web.WebEngine"); … … 110 122 State = classLoader.loadClass("javafx.concurrent.Worker$State"); 111 123 StateConstants = Arrays.asList(State.getEnumConstants()); 124 125 EventHandler = classLoader.loadClass("javafx.event.EventHandler"); 126 127 Node = classLoader.loadClass("javafx.scene.Node"); 128 NodeSetOnMouseClicked = Node.getMethod("setOnMouseClicked", EventHandler); 129 130 MouseEvent = classLoader.loadClass("javafx.scene.input.MouseEvent"); 131 MouseEventGetButton = MouseEvent.getMethod("getButton"); 132 133 MouseButton = classLoader.loadClass("javafx.scene.input.MouseButton"); 112 134 113 135 JSObject = classLoader.loadClass("netscape.javascript.JSObject");
Note:
See TracChangeset
for help on using the changeset viewer.