Package com.sun.javafx.scene.text

Examples of com.sun.javafx.scene.text.HitInfo


            default: // do nothing
        }
    }

    private void leftPress(ParagraphBox<?> cell, MouseEvent e) {
        HitInfo hit = hitCell(cell, e);

        if(e.isShiftDown()) {
            // On Mac always extend selection,
            // switching anchor and caret if necessary.
            area.moveTo(hit.getInsertionIndex(), isMac() ? SelectionPolicy.EXTEND : SelectionPolicy.ADJUST);
        } else {
            switch (e.getClickCount()) {
                case 1: firstLeftPress(hit); break;
                case 2: selectWord(); break;
                case 3: area.selectLine(); break;
View Full Code Here


        if(e.getButton() != MouseButton.PRIMARY || e.isMiddleButtonDown() || e.isSecondaryButtonDown()) {
            return;
        }

        // get the position within text
        HitInfo hit = hitCell(cell, e);

        if(dragSelection == DragState.DRAG) {
            area.positionCaret(hit.getInsertionIndex());
        } else {
            area.moveTo(hit.getInsertionIndex(), SelectionPolicy.ADJUST);
        }
    }
View Full Code Here

    private void mouseReleased(ParagraphBox<?> cell, MouseEvent e) {
        switch(dragSelection) {
            case POTENTIAL_DRAG:
                // drag didn't happen, position caret
                HitInfo hit = hitCell(cell, e);
                area.moveTo(hit.getInsertionIndex(), SelectionPolicy.CLEAR);
                break;
            case DRAG:
                // do nothing, handled by mouseDragReleased
            case NO_DRAG:
                // do nothing, caret already repositioned in mousePressed
View Full Code Here

            return;
        }

        if(dragSelection == DragState.DRAG) {
            // get the position within text
            HitInfo hit = hitCell(cell, e);

            area.moveSelectedText(hit.getInsertionIndex());
        }
    }
View Full Code Here

            return hit;
        }).orElseGet(() -> leadingEdgeOf(cellOffset + cell.getParagraph().length()));
    }

    private static HitInfo leadingEdgeOf(int charIdx) {
        HitInfo hit = new HitInfo();
        hit.setCharIndex(charIdx);
        hit.setLeading(true);
        return hit;
    }
View Full Code Here

        if(paragraph.length() == 0) {
            return Optional.empty();
        }

        TextLayout textLayout = textLayout();
        HitInfo hit = textLayout.getHitInfo((float)x, (float)y);

        if(hit.getCharIndex() == paragraph.length() - 1) {
            // Might be a hit beyond the end of line, investigate.
            // Workaround for https://javafx-jira.kenai.com/browse/RT-37803
            PathElement[] elems = textLayout.getCaretShape(paragraph.length(), true, 0, 0);
            Path caret = new Path(elems);
            if(x > caret.getBoundsInLocal().getMinX()) {
View Full Code Here

          // Calculate to text flow
          p = p.subtract(flow.getLayoutX(), flow.getLayoutY());
          for( Node n : flow.getChildren() ) {
            Text text = (Text) n;
            if( text.getBoundsInParent().contains(p) ) {
              HitInfo info = text.impl_hitTestChar(new Point2D(p.getX()-text.getLayoutX(), 0 /* See RT-28485 text.getLayoutY()*/));
              if( info.getInsertionIndex() >= 0 ) {
//                System.err.println("Text: " + text.getText());
//                System.err.println("Text-Offset: " + text.getUserData());
//                System.err.println("INSERT INDEX: " + info.getInsertionIndex());
                int offset = ((Integer)text.getUserData()).intValue()+info.getInsertionIndex();
//                System.err.println("NEW OFFSET AT: " + offset);
                getControl().setCaretOffset(offset);
                return;
              }
            }
View Full Code Here

TOP

Related Classes of com.sun.javafx.scene.text.HitInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.