neilcsmith-net commented on code in PR #9812:
URL: https://github.com/apache/netbeans/pull/9812#discussion_r4630562786
##########
platform/core.output2/src/org/netbeans/core/output2/ui/AbstractOutputPane.java:
##########
@@ -1025,4 +1037,237 @@ public void setSelectionVisible(boolean vis) {
}
}
}
+
+
+ private static class HoverSupport {
+ private final JEditorPane pane;
+
+ private Object hightlightHandle;
+ private int[] highlightRange;
+ private Point lastMouse; // so key presses can re-evaluate
without mouse movement
+
+ public HoverSupport(JEditorPane pane) {
+ this.pane = pane;
+
+ MouseAdapter mouse = new MouseAdapter() {
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ lastMouse = e.getPoint();
+ update(isCtrlDown(e));
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ clear();
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ lastMouse = null;
+ clear();
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (isCtrlDown(e) && highlightRange != null) {
+ onActivate(highlightRange[0], highlightRange[1]);
+ e.consume();
+ }
+ }
+ };
+ pane.addMouseListener(mouse);
+ pane.addMouseMotionListener(mouse);
+
+ pane.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ update(isCtrlDown(e));
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ update(isCtrlDown(e));
+ }
+ });
+ }
+
+ private static boolean isCtrlDown(InputEvent e) {
+ // Cmd on Mac OS X, Ctrl elsewhere
+ int MOD = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
+ return (e.getModifiersEx() & MOD) != 0;
+ }
+
+ private void update(boolean modifierDown) {
+ if (!modifierDown || lastMouse == null) {
+ clear();
+ return;
+ }
+
+ int offset = offsetAt(lastMouse);
+ if (offset < 0) {
+ clear();
+ return;
+ }
+
+ try {
+ int[] startEnd = findPathBoundaries(pane, offset);
Review Comment:
Yes, this sounds problematic. Is this important? Is looks like a path
enough? I've certainly got other software that doesn't differentiate until a
click is made.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists