@@ -78,7 +78,7 @@ public class EditorStatus extends BasicSplitPaneDivider { //JPanel {
7878 String url ;
7979 int rightEdge ;
8080 int mouseX ;
81- boolean inside ;
81+ boolean urlRollover ;
8282
8383 Font font ;
8484 FontMetrics metrics ;
@@ -108,7 +108,7 @@ public void mouseEntered(MouseEvent e) {
108108
109109 @ Override
110110 public void mousePressed (MouseEvent e ) {
111- if (inside ) {
111+ if (urlRollover ) {
112112 Platform .openURL (url );
113113 }
114114 }
@@ -132,7 +132,7 @@ public void mouseMoved(MouseEvent e) {
132132
133133
134134 void updateMouse () {
135- if (inside ) {
135+ if (urlRollover ) {
136136 setCursor (Cursor .getPredefinedCursor (Cursor .HAND_CURSOR ));
137137 } else {
138138 setCursor (Cursor .getPredefinedCursor (Cursor .MOVE_CURSOR ));
@@ -292,13 +292,19 @@ public void paint(Graphics screen) {
292292 g .setColor (fgColor [mode ]);
293293 // https://github.com/processing/processing/issues/3265
294294 if (message != null ) {
295- g .setFont (font ); // needs to be set each time on osx
296- inside = (mouseX > LEFT_MARGIN && mouseX < rightEdge );
297- if (inside ) {
295+ // needs to be set each time on osx
296+ g .setFont (font );
297+ // calculate right edge of the text for rollovers (otherwise the pane
298+ // cannot be resized up or down whenever a URL is being displayed)
299+ rightEdge = LEFT_MARGIN + g .getFontMetrics ().stringWidth (message );
300+ // set the highlight color on rollover so that the user's not surprised
301+ // to see the web browser open when they click
302+ urlRollover = (url != null ) &&
303+ (mouseX > LEFT_MARGIN && mouseX < rightEdge );
304+ if (urlRollover ) {
298305 g .setColor (urlColor );
299306 }
300307 g .drawString (message , LEFT_MARGIN , (sizeH + ascent ) / 2 );
301- rightEdge = LEFT_MARGIN + g .getFontMetrics ().stringWidth (message );
302308 }
303309
304310 if (indeterminate ) {
0 commit comments