diff options
author | Felipe Heidrich <fheidric> | 2008-11-24 17:14:33 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2008-11-24 17:14:33 +0000 |
commit | 564c1c02092bc5f4dfec4f8dc3e60bb885088713 (patch) | |
tree | ca20956f0bc64e0e2586d67083fe61b2ac55d103 | |
parent | 04bdad09dcfe1dc53f646d4eaa792524245ec09d (diff) | |
download | eclipse.platform.swt-564c1c02092bc5f4dfec4f8dc3e60bb885088713.tar.gz eclipse.platform.swt-564c1c02092bc5f4dfec4f8dc3e60bb885088713.tar.xz eclipse.platform.swt-564c1c02092bc5f4dfec4f8dc3e60bb885088713.zip |
Bug 256261: Hand cursor stays when releasing Ctrl after hovering a link
2 files changed, 26 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java index 1018065523..ed6cbdb081 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java @@ -2646,6 +2646,26 @@ void doLineUp(boolean select) { int hScrollChange = oldHScrollOffset - horizontalScrollOffset; columnX = oldColumnX + hScrollChange; } +void doMouseLinkCursor() { + Display display = getDisplay(); + Point point = display.getCursorLocation(); + point = display.map(null, this, point); + doMouseLinkCursor(point.x, point.y); +} +void doMouseLinkCursor(int x, int y) { + int offset = getOffsetAtPoint(x, y, null, true); + Display display = getDisplay(); + Cursor newCursor = cursor; + if (renderer.hasLink(offset)) { + newCursor = display.getSystemCursor(SWT.CURSOR_HAND); + } else { + if (cursor == null) { + int type = blockSelection ? SWT.CURSOR_CROSS : SWT.CURSOR_IBEAM; + newCursor = display.getSystemCursor(type); + } + } + if (newCursor != getCursor()) super.setCursor(newCursor); +} /** * Moves the caret to the specified location. * @@ -5749,18 +5769,7 @@ void handleMouseMove(Event event) { doMouseLocationChange(event.x, event.y, true); } if (renderer.hasLinks) { - int offset = getOffsetAtPoint(event.x, event.y, null, true); - Display display = getDisplay(); - Cursor newCursor = cursor; - if (renderer.hasLink(offset)) { - newCursor = display.getSystemCursor(SWT.CURSOR_HAND); - } else { - if (cursor == null) { - int type = blockSelection ? SWT.CURSOR_CROSS : SWT.CURSOR_IBEAM; - newCursor = display.getSystemCursor(type); - } - } - if (newCursor != getCursor()) super.setCursor(newCursor); + doMouseLinkCursor(event.x, event.y); } } /** @@ -6611,6 +6620,7 @@ public void redraw() { renderer.reset(topIndex, itemCount); renderer.calculate(topIndex, itemCount); setScrollBars(false); + doMouseLinkCursor(); } /** * Causes the rectangular area of the receiver specified by @@ -6648,6 +6658,7 @@ public void redraw(int x, int y, int width, int height, boolean all) { int firstLine = getLineIndex(y); int lastLine = getLineIndex(y + height); resetCache(firstLine, lastLine - firstLine + 1); + doMouseLinkCursor(); } } void redrawLines(int startLine, int lineCount) { @@ -6725,6 +6736,7 @@ public void redrawRange(int start, int length, boolean clearBackground) { int lastLine = content.getLineAtOffset(end); resetCache(firstLine, lastLine - firstLine + 1); internalRedrawRange(start, length); + doMouseLinkCursor(); } /** * Removes the specified bidirectional segment listener. @@ -8636,6 +8648,7 @@ void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles, bo } } setCaretLocation(); + doMouseLinkCursor(); } /** * Sets styles to be used for rendering the widget content. All styles diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java index df7476c6fb..d963694436 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java @@ -515,6 +515,7 @@ boolean hasLink(int offset) { if (ranges != null) { int rangeCount = styleCount << 1; int index = getRangeIndex(offset, -1, rangeCount); + if (index >= rangeCount) return false; int rangeStart = ranges[index]; int rangeLength = ranges[index + 1]; StyleRange rangeStyle = styles[index >> 1]; |