Ignore:
Timestamp:
12/05/13 16:36:38 (11 years ago)
Author:
csl14
Message:

added ItemsRightClickedDropped and ItemsLeftClickedDropped for expeditee like text-widget interaction for the url field in JfxBrowser

Location:
trunk/src/org/expeditee/items/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/widgets/InteractiveWidget.java

    r567 r573  
    17231723       
    17241724        /**
    1725          * Event called when the widget is left clicked while there are items attached to the FreeItems buffer
    1726          *
    1727          * @return true if event was handled (no pass through), otherwise false
     1725         * Event called when the widget is left clicked while there are items attached to the FreeItems buffer.
     1726         * Used to enable expeditee like text-widget interaction for left mouse clicks.
     1727         * @return true if event was handled (no pass through), otherwise false.
    17281728         */
    17291729        public boolean ItemsLeftClickDropped() {
     
    17321732       
    17331733        /**
    1734          * Event called when the widget is middle clicked while there are items attached to the FreeItems buffer
    1735          *
    1736          * @return true if event was handled (no pass through), otherwise false
     1734         * Event called when the widget is middle clicked while there are items attached to the FreeItems buffer.
     1735         * Used to enable expeditee like text-widget interaction for middle mouse clicks.
     1736         * @return true if event was handled (no pass through), otherwise false.
    17371737         */
    17381738        public boolean ItemsMiddleClickDropped() {
    1739                 System.out.println("MiddleClickDropped");
    17401739                return false;
    17411740        }
    17421741       
    17431742        /**
    1744          * Event called when the widget is left clicked while there are items attached to the FreeItems buffer
    1745          *
    1746          * @return true if event was handled (no pass through), otherwise false
     1743         * Event called when the widget is left clicked while there are items attached to the FreeItems buffer.
     1744         * Used to enable expeditee like text-widget interaction for right mouse clicks
     1745         * @return true if event was handled (no pass through), otherwise false.
    17471746         */
    17481747        public boolean ItemsRightClickDropped() {
    1749                 System.out.println("RightClickDropped");
    17501748                return false;
    17511749        }
  • trunk/src/org/expeditee/items/widgets/JfxBrowser.java

    r570 r573  
    44import java.awt.Color;
    55import java.awt.Component;
     6import java.awt.Point;
    67import java.awt.event.ActionEvent;
    78import java.awt.event.ActionListener;
     
    2526import org.expeditee.gui.DisplayIO;
    2627import org.expeditee.gui.FrameMouseActions;
    27 import org.expeditee.gui.FrameUtils;
    2828import org.expeditee.gui.FreeItems;
    2929import org.expeditee.gui.MessageBay;
     
    4646        private static final String REFRESH = "refresh";
    4747        private static final String GETFRAME = "getframe";
     48       
     49        public static final int VERT_OFFSET = 50;
     50        public static final int VERT_CROP = 88;
     51        public static final int HORZ_CROP = 15;
    4852       
    4953        private WebBrowserPanel _browser;
     
    333337                                                               
    334338                                                                if(JavaFX.MouseEventGetButton.invoke(args[0]).equals(buttonEnum[1])) /* Left Mouse Button */ {
    335 /*$#remove*/System.err.println("Left Button Clicked");
     339                                                                       
    336340                                                                } else if(JavaFX.MouseEventGetButton.invoke(args[0]).equals(buttonEnum[2])) /* Middle Mouse Button */ {
    337 /*$#remove*/System.err.println("Middle Button Clicked");
     341                                                                       
    338342                                                                } else if(JavaFX.MouseEventGetButton.invoke(args[0]).equals(buttonEnum[3])) /* Right Mouse Button */ {
    339 /*$#remove*/System.err.println("Right Button Clicked");
    340343                                                                        // Gets text currently selected in webview
    341344                                                                        String selection = (String) JavaFX.WebEngineExecuteScript.invoke(JavaFX.WebViewGetEngine.invoke(webview), "window.getSelection().toString()");
     
    574577        }
    575578
     579        /**
     580         * Used to enable expeditee like text-widget interaction for middle mouse clicks. Does nothing if a text item is not attached to cursor.
     581         * @return false if a text-widget interaction did not occur, true if a text-widget interaction did occur.
     582         */
     583        @Override
     584        public boolean ItemsMiddleClickDropped() {
     585                Text t = null;
     586                if((t = FreeItems.getTextAttachedToCursor()) == null) { // fails if no text item is attached to the cursor.
     587                        return false;
     588                }
     589
     590                Point p = new Point(FrameMouseActions.getX() - this.getX(), FrameMouseActions.getY() - this.getY());
     591
     592                if(!_browser.urlField.contains(p)) {                                    // fails if not clicking on urlField
     593                        return false;
     594                }
     595
     596                // Inserts text in text item into urlField at the position of the mouse.
     597                String s = _browser.urlField.getText();
     598                int index = _browser.urlField.viewToModel(new Point(p.x - _browser.urlField.getX(), p.y - _browser.urlField.getY()));
     599                s = s.substring(0, index) + t.getText() + s.substring(index);
     600                _browser.urlField.setText(s);
     601
     602                FreeItems.getInstance().clear();                                                // removed held text item - like normal expeditee middle click behaviour.
     603
     604                return true;
     605        }
     606       
     607        /**
     608         * Used to enable expeditee like text-widget interaction for right mouse clicks. Does nothing if a text item is not attached to cursor.
     609         * @return false if a text-widget interaction did not occur, true if a text-widget interaction did occur.
     610         */
     611        @Override
     612        public boolean ItemsRightClickDropped() {
     613                Text t = null;
     614                if((t = FreeItems.getTextAttachedToCursor()) == null) { // fails if no text item is attached to the cursor.
     615                        return false;
     616                }
     617
     618                Point p = new Point(FrameMouseActions.getX() - this.getX(), FrameMouseActions.getY() - this.getY());
     619
     620                if(!_browser.urlField.contains(p)) {                                    // fails if not clicking on urlField
     621                        return false;
     622                }
     623
     624                // Inserts text in text item into urlField at the position of the mouse.
     625                String s = _browser.urlField.getText();
     626                int index = _browser.urlField.viewToModel(new Point(p.x - _browser.urlField.getX(), p.y - _browser.urlField.getY()));
     627                s = s.substring(0, index) + t.getText() + s.substring(index);
     628                _browser.urlField.setText(s);
     629
     630                return true;
     631        }
     632       
    576633        @Override
    577634        protected String[] getArgs() {
Note: See TracChangeset for help on using the changeset viewer.