Community
Participate
Working Groups
Mac only: - Create new project - Create new text WSIWIG example. - Select some text within the example. Result: - text disappears
We will have to add platform specific code in TextFlow. Also, the default drag feedback uses XOR, as does the Marquee Rectangle.
If you change TextFlow to this it works pretty well: /** * @see InlineFlow#paintSelection(org.eclipse.draw2d.Graphics) */ protected void paintSelection(Graphics graphics) { if (selectionStart == -1) return; if (isXORCapable) { graphics.setXORMode(true); graphics.setBackgroundColor(ColorConstants.white); } else { int selectionAlpha = 140; graphics.setAlpha(selectionAlpha); Display display = Display.getCurrent(); Color selectionColor = (display != null) ? display.getSystemColor(SWT.COLOR_LIST_SELECTION) : ColorConstants.menuBackgroundSelected; graphics.setBackgroundColor(selectionColor); } TextFragmentBox frag; for (int i = 0; i < fragments.size(); i++) { [...same as current...] } } It certainly would be preferable to have this over selection erasing the selected text as it does now. Ultimately it would be preferable to have TextFlow.paintText always use Graphics.drawTextLayout(TextLayout, int, int, int, int, Color, Color) to draw the text with selection. Though this doesn't highlight the border drawing its not clear this is even desireable. Am I missing something?
Instead of using XOR for text selection highlighting having the TextLayout render the highlighted text works great. This works quite well: 1) add to TextFlow: private void paintTextWithSelection(Graphics g, String draw, int x, int y, int startSelection, int endSelection) { TextLayout tl = FlowUtilities.getTextLayout(); if (isMirrored()) tl.setOrientation(SWT.RIGHT_TO_LEFT); tl.setFont(g.getFont()); tl.setText(draw); Color selectionForeground = ColorConstants.menuForegroundSelected; Color selectionBackground = ColorConstants.menuBackgroundSelected; g.drawTextLayout(tl, x, y, startSelection, endSelection, selectionForeground, selectionBackground); } 2) in TextFlow.paintFigure() do this instead of paintText: int selStart = -1, selEnd = -1; if (selectionStart != -1 && selectionStart < frag.offset + frag.length && frag.offset <= selectionEnd) { selStart = Math.max(selectionStart - frag.offset, 0); selEnd = Math.min(selectionEnd - frag.offset, frag.offset + frag.length) - 1; selEnd += (selEnd < 0) ? 0 : getBidiPrefixLength(frag, i); } paintTextWithSelection(g, draw, frag.getX(), frag.getBaseline() - getAscent(), selStart, selEnd);
Verified that with Eclipse 3.6.1 this no longer occurs on Mac OS X Carbon (10.4.11, Java 5) and - with the now implemented XOR functionality on Mac Cocoa - that with Eclipse 3.7 N20101218 this no longer occurs on Mac OS X Cocoa as well. Resolving as fixed in 3.7.
(In reply to comment #4) > Verified that with Eclipse 3.6.1 this no longer occurs on Mac OS X Carbon > (10.4.11, Java 5) and - with the now implemented XOR functionality on Mac Cocoa > - that with Eclipse 3.7 N20101218 this no longer occurs on Mac OS X Cocoa as > well. Resolving as fixed in 3.7. Since XOR works on the Mac now, has SWT undeprecated that API?
(In reply to comment #5) > (In reply to comment #4) > > Verified that with Eclipse 3.6.1 this no longer occurs on Mac OS X Carbon > > (10.4.11, Java 5) and - with the now implemented XOR functionality on Mac Cocoa > > - that with Eclipse 3.7 N20101218 this no longer occurs on Mac OS X Cocoa as > > well. Resolving as fixed in 3.7. > > Since XOR works on the Mac now, has SWT undeprecated that API? From Scott's comment to 332872 I cannot infer that this has officially been done yet. However, he implemented the respective functionality for 3.7, so maybe it would be worth issuing a request for this.
(In reply to comment #6) > (In reply to comment #5) > > (In reply to comment #4) > > > Verified that with Eclipse 3.6.1 this no longer occurs on Mac OS X Carbon > > > (10.4.11, Java 5) and - with the now implemented XOR functionality on Mac Cocoa > > > - that with Eclipse 3.7 N20101218 this no longer occurs on Mac OS X Cocoa as > > > well. Resolving as fixed in 3.7. > > > > Since XOR works on the Mac now, has SWT undeprecated that API? > > From Scott's comment to 332872 I cannot infer that this has officially been > done yet. However, he implemented the respective functionality for 3.7, so > maybe it would be worth issuing a request for this. FYI: bug #333391 has been raised to handle the un-deprecation of GC#setXorMode().