Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-09-03 18:28:42 +0000
committerPaul Pazderski2019-09-27 12:33:18 +0000
commitcde755d8c88e25a6c957b9983ba314e2d669e205 (patch)
tree7cbf156e39df1d8b8fe0727d886e3d660fe797b6
parent5d0b3237356366721c8fdc1d12d71063353900b5 (diff)
downloadeclipse.platform.swt-cde755d8c88e25a6c957b9983ba314e2d669e205.tar.gz
eclipse.platform.swt-cde755d8c88e25a6c957b9983ba314e2d669e205.tar.xz
eclipse.platform.swt-cde755d8c88e25a6c957b9983ba314e2d669e205.zip
Bug 550717 - [Win32] Wrong focus highlight with multi-link SysLink and
mnemonics Current implementation can fail to remove focus indication when changing focus by using mnemonics. Change-Id: Ic41cd6004423eb2ccf64f946f5caf3ee592c1d36 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
index 3b483dd8c6..bb1aeee1d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
@@ -447,23 +447,36 @@ public void removeSelectionListener (SelectionListener listener) {
}
boolean setFocusItem (int index) {
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int bits = 0;
+ if (index > 0) {
+ bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ }
LITEM item = new LITEM ();
item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
item.stateMask = OS.LIS_FOCUSED;
- while (item.iLink < ids.length) {
- if (item.iLink != index) OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
- item.iLink++;
+ int activeIndex = getFocusItem ();
+ if (activeIndex == index) return true;
+ if (activeIndex >= 0) {
+ /* Feature in Windows. Unfocus any element unfocus all elements.
+ * For example if item 2 is focused and we set unfocus (state = 0)
+ * for item 0 Windows will remove the focus state for item 2
+ * (getFocusItem() == -1) but fail to remove the focus border around
+ * the link. The fix is to only unfocus the element which has focus.
+ */
+ item.iLink = activeIndex;
+ OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
}
item.iLink = index;
item.state = OS.LIS_FOCUSED;
long result = OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
- /* Feature in Windows. For some reason, setting the focus to
- * any item but first causes the control to clear the WS_TABSTOP
- * bit. The fix is always to reset the bit.
- */
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ if (index > 0) {
+ /* Feature in Windows. For some reason, setting the focus to
+ * any item but first causes the control to clear the WS_TABSTOP
+ * bit. The fix is always to reset the bit.
+ */
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
return result != 0;
}

Back to the top