diff options
author | Felipe Heidrich <fheidric> | 2007-09-13 19:58:22 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2007-09-13 19:58:22 +0000 |
commit | fe495be3ccb10f369847493f43f449a5b9d6432f (patch) | |
tree | fd1b1f100da6582172d17b60b8acdac4f394af5a /bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java | |
parent | 3aff16acfdf77e96d907ad171748ade5965df079 (diff) | |
download | eclipse.platform.swt-fe495be3ccb10f369847493f43f449a5b9d6432f.tar.gz eclipse.platform.swt-fe495be3ccb10f369847493f43f449a5b9d6432f.tar.xz eclipse.platform.swt-fe495be3ccb10f369847493f43f449a5b9d6432f.zip |
fix for FEEDBACK_SELECT
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java index 6d0d162420..1b81203367 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java @@ -192,53 +192,10 @@ public class StyledTextDropTargetEffect extends DropTargetEffect { } if ((effect & DND.FEEDBACK_SELECT) != 0) { - StyledTextContent content = text.getContent(); - int newOffset = -1; - try { - newOffset = text.getOffsetAtLocation(pt); - } catch (IllegalArgumentException ex1) { - int maxOffset = content.getCharCount(); - Point maxLocation = text.getLocationAtOffset(maxOffset); - if (pt.y >= maxLocation.y) { - try { - newOffset = text.getOffsetAtLocation(new Point(pt.x, maxLocation.y)); - } catch (IllegalArgumentException ex2) { - newOffset = maxOffset; - } - } else { - try { - int startOffset = text.getOffsetAtLocation(new Point(0, pt.y)); - int endOffset = maxOffset; - int line = content.getLineAtOffset(startOffset); - int lineCount = content.getLineCount(); - if (line + 1 < lineCount) { - endOffset = content.getOffsetAtLine(line + 1) - 1; - } - int lineHeight = text.getLineHeight(startOffset); - for (int i = endOffset; i >= startOffset; i--) { - Point p = text.getLocationAtOffset(i); - if (p.x < pt.x && p.y < pt.y && p.y + lineHeight > pt.y) { - newOffset = i; - break; - } - } - } catch (IllegalArgumentException ex2) { - newOffset = -1; - } - } - } - if (newOffset != -1 && newOffset != currentOffset) { - // check if offset is line delimiter - // see StyledText.isLineDelimiter() - int line = content.getLineAtOffset(newOffset); - int lineOffset = content.getOffsetAtLine(line); - int offsetInLine = newOffset - lineOffset; - // offsetInLine will be greater than line length if the line - // delimiter is longer than one character and the offset is set - // in between parts of the line delimiter. - if (offsetInLine > content.getLine(line).length()) { - newOffset = Math.max(0, newOffset - 1); - } + int[] trailing = new int [1]; + int newOffset = text.getOffsetAtPoint(pt.x, pt.y, trailing, false); + newOffset += trailing [0]; + if (newOffset != currentOffset) { refreshCaret(text, currentOffset, newOffset); currentOffset = newOffset; } |