summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2009-09-21 14:43:16 +0000
committerFelipe Heidrich <fheidric>2009-09-21 14:43:16 +0000
commitb2239f422123a88b15e65957a6af7c2681a90cab (patch)
treee4873cb70a2bb08a293496d56357d92192b764f2 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
parentac8aa4ed15146cebc36dd156b93099ccf8e75814 (diff)
downloadeclipse.platform.swt-b2239f422123a88b15e65957a6af7c2681a90cab.tar.gz
eclipse.platform.swt-b2239f422123a88b15e65957a6af7c2681a90cab.tar.xz
eclipse.platform.swt-b2239f422123a88b15e65957a6af7c2681a90cab.zip
Bug 202414 - Link widget has problems with mnemonics
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java55
1 files changed, 55 insertions, 0 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 bf0d12ea71..6d5f14915f 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
@@ -412,6 +412,61 @@ public String getText () {
return text;
}
+boolean mnemonicHit (char key) {
+ if (mnemonics != null) {
+ char uckey = Character.toUpperCase (key);
+ String parsedText = parse(text);
+ for (int i = 0; i < mnemonics.length - 1; i++) {
+ if (mnemonics[i] != -1) {
+ char mnemonic = parsedText.charAt(mnemonics[i]);
+ if (uckey == Character.toUpperCase (mnemonic)) {
+ if (!setFocus ()) return false;
+ if (OS.COMCTL32_MAJOR >= 6) {
+ int 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 < mnemonics.length) {
+ if (item.iLink != i) OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
+ item.iLink++;
+ }
+ item.iLink = i;
+ item.state = OS.LIS_FOCUSED;
+ 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);
+ } else {
+ focusIndex = i;
+ redraw ();
+ }
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+boolean mnemonicMatch (char key) {
+ if (mnemonics != null) {
+ char uckey = Character.toUpperCase (key);
+ String parsedText = parse(text);
+ for (int i = 0; i < mnemonics.length - 1; i++) {
+ if (mnemonics[i] != -1) {
+ char mnemonic = parsedText.charAt(mnemonics[i]);
+ if (uckey == Character.toUpperCase (mnemonic)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
String parse (String string) {
int length = string.length ();
offsets = new Point [length / 4];