public void processMousePressed(MousePressedEvent e) { final Panel panel = e.getRecipient(); inWordSelectionMode = false; TextLocation location = model.getLocationAt(e.getLocation()); model.startSelection(location); model.setCaretLocation(location, XOffsetStrategy.FITTING, YOffsetStrategy.FITTING); model.setCaretOn(true); handleMultipleClicks(e); panel.markAsDirty(); panel.getStage().getKeyListener().focusOn(panel); lastClickTime = System.currentTimeMillis(); }
public void processMouseDragged(MouseDraggedEvent e) { Point mousePoint = e.getLocation(); ArrayList<TypedLayout> lines = model.getLines(); TextLocation tempLocation = model.getLocationAt(mousePoint); // TODO MDM - This needs work. Ideally, the text will scroll smoothly, a pixel at a time, // without the mouse moving. The scoll speed increased as the mouse moves away. if (mousePoint.x < 3 && tempLocation.index > 0) tempLocation = tempLocation.moved(lines, -1); else if (mousePoint.x > (model.getContainer().getWidth() - 3) && tempLocation.atEnd(lines)) tempLocation = tempLocation.moved(lines, +1); if (inWordSelectionMode) selectWord(tempLocation); else model.setCaretLocation(tempLocation, XOffsetStrategy.FITTING, YOffsetStrategy.FITTING); e.getRecipient().markAsDirty(); }