Skip to content

Commit 286ebb5

Browse files
committed
deal with url rollover bugs in the status bar (fixes #4695)
1 parent a43f724 commit 286ebb5

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

app/src/processing/app/ui/EditorStatus.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

todo.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ X https://github.com/processing/processing/commit/8a3a183f327a5ee680e1932dd9f1
1414
X more font tweaks to make mono fonts work properly after #4639
1515
_ update the Linux notes based on where we land on this
1616
_ https://github.com/processing/processing/wiki/Supported-Platforms#linux
17-
_ "Could not open the url" when clicking on the error message
18-
_ https://github.com/processing/processing/issues/4695
17+
X "Could not open the url" when clicking on the error message
18+
X https://github.com/processing/processing/issues/4695
1919
_ launch4j bug with minimum JRE version (set to 102 for folks who have 101?)
2020
_ https://github.com/processing/processing/issues/4682
2121
_ sharing usage metrics about libraries

0 commit comments

Comments
 (0)