Fixed selection bug in post window.

This commit is contained in:
Snowyfox 2022-05-21 23:43:06 -04:00
parent 150773de8b
commit b4bfebc80a

View File

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