Behavioural differences of redraw() between Win7 and Win10 [message #1734088] |
Fri, 03 June 2016 16:20 |
Ralf Grossklaus Messages: 3 Registered: October 2015 |
Junior Member |
|
|
Hello,
I've experienced some very strange behaviour of the Hyperlink widget on Windows 10 x64 (It works fine on Windows 7 x64, haven't tested it on other platforms). Under some circumstances (which i mention below), when moving the mouse cursor over the widget, it will recieve a SWT.MouseExit event without ever getting a SWT.MouseEnter event in the first place. The following code snippet demonstrates this, when moving the cursor over the hyperlink widgets from the top to the bottom of the window:
import static com.ibm.icu.text.MessageFormat.format;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.Hyperlink;
public class HyperlinkExample {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
final String[] links = new String[] {
"Link one",
"Link two",
"Link three",
"Link four",
"Link five",
"Link six",
"Link seven",
"Link eight",
"Link nine",
"Link ten"
};
for (final String linkText : links) {
createLink(shell, linkText);
}
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
private static void createLink(Composite parent, final String text) {
final Hyperlink link = new Hyperlink(parent, SWT.LEFT);
link.setText(text);
link.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
link.setToolTipText(format("ToolTip {0}", text));
link.addMouseTrackListener(new MouseTrackListener() {
@Override
public void mouseHover(MouseEvent e) {
}
@Override
public void mouseExit(MouseEvent e) {
System.out.println(format("## Link({0})->mouseExit()", text)); //$NON-NLS-1$
}
@Override
public void mouseEnter(MouseEvent e) {
System.out.println(format("## Link({0})->mouseEnter()", text)); //$NON-NLS-1$
}
});
}
}
I know, AbstractHyperlink is a custom widget and is not part of SWT, however the problem (as i found out) is not in the widget itself, but in the implementation of Control.redraw(false) which directs to the native implementation of OS.RedrawWindow(). This method is called on SWT.MouseExit of a Hyperlink (see AbstractHyperlink.handleExit()) and after calling this, the SWT.MouseEnter event is somehow lost. Another thing i found out is, that this fails only if a tool tip is set to the hyperlink.
Does anybody who is a bit more familiar to the windows implementation of SWT know what's the actual problem here?
Regards,
Ralf
|
|
|
|
Powered by
FUDForum. Page generated in 0.03258 seconds