- Timestamp:
- Sep 30, 2009, 1:25:14 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/MenuItem.java
r118 r192 383 383 } 384 384 385 /* convert all Eclipse mnemonic prefixes to OS/2 mnemonic prefixes */ 386 String patchMnemonics (String string) { 387 StringBuffer buf = new StringBuffer (string); 388 /* the last mnemonic char takes precedence over others if any */ 389 int mnemonicIdx = string.lastIndexOf (Mnemonic); 390 boolean lastIsMnemonic = false; 391 for (int i = 0; i < buf.length(); i++) { 392 boolean isMnemonic = buf.charAt (i) == Mnemonic; 393 if (lastIsMnemonic) { 394 if (isMnemonic) { 395 buf.deleteCharAt (i--); 396 if (mnemonicIdx >= 0) mnemonicIdx --; 397 lastIsMnemonic = false; 398 continue; 399 } else { 400 if ((i - 1) == mnemonicIdx) { 401 buf.replace (i - 1, i, "~"); 402 mnemonicIdx = -1; 403 } else { 404 buf.deleteCharAt ((i--) - 1); 405 if (mnemonicIdx >= 0) mnemonicIdx --; 406 } 407 } 408 } 409 if (!isMnemonic) { 410 if (buf.charAt (i) == '~') { 411 buf.insert (i++, '~'); 412 if (mnemonicIdx >= 0) mnemonicIdx ++; 413 } 414 } 415 lastIsMnemonic = isMnemonic; 416 } 417 if (lastIsMnemonic) { 418 buf.setLength (buf.length() - 1); 419 } 420 return buf.toString(); 421 } 422 385 423 void releaseChild () { 386 424 super.releaseChild (); … … 668 706 super.setText (string); 669 707 int hMenu = parent.handle; 708 string = patchMnemonics (string); 670 709 PSZ buffer = new PSZ(string); 671 710 int rc = OS.WinSendMsg (hMenu, OS.MM_SETITEMTEXT, (short)id, buffer);
Note:
See TracChangeset
for help on using the changeset viewer.