diff --git a/RichTextPane3.java b/RichTextPane3.java index 0b14c07..3a2c5a7 100644 --- a/RichTextPane3.java +++ b/RichTextPane3.java @@ -369,6 +369,7 @@ implements selStart = identifyNodeAt(eM.getX(), eM.getY()); selEnd = null; repaint(); + requestFocusInWindow(); } public void @@ -450,16 +451,18 @@ implements keyPressed(KeyEvent eK) { if (!eK.isControlDown()) return; + switch (eK.getKeyCode()) { case KeyEvent.VK_C: + if (selEnd == null) return; ClipboardApi.serve(getSelectedText()); - break; + return; case KeyEvent.VK_A: selStart = identifyNodeAt(0, 0); selEnd = layoutEnd; repaint(); - break; + return; } } @@ -485,9 +488,9 @@ implements Position position = layout.get(node); assert position != null; - boolean after = position.compareTo(ssp) > 0; + boolean after = position.compareTo(ssp) >= 0; boolean before = position.compareTo(sep) < 0; - if (!(after || before)) continue; + if (!(after && before)) continue; // Just throw them in a pile for now.. selected.add(node); @@ -619,6 +622,12 @@ implements return 0; } + public String + toString() + { + return "(" + x + "," + line + ")"; + } + // -=%=- public @@ -655,6 +664,8 @@ implements this.addMouseMotionListener(this); this.addKeyListener(this); setFocusable(true); + // A keyboard user can still copy by tabbing in + // and selecting all. } }