Bug 202414 - Link widget has problems with mnemonics
Summary: Link widget has problems with mnemonics
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 276621 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-06 05:54 EDT by Dani Megert CLA
Modified: 2009-10-29 03:56 EDT (History)
3 users (show)

See Also:


Attachments
Fix (1.36 KB, patch)
2009-09-14 14:59 EDT, Markus Keller CLA
no flags Details | Diff
patch (2.30 KB, patch)
2009-09-16 16:29 EDT, Felipe Heidrich CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2007-09-06 05:54:34 EDT
R3.3 and I20070529-0010.

Links.setText(String) claims it allows mnemonics. I added one into the normal text and I also tried to put one into the link text (i.e. between <a> and </a>) but they are only rendered in the UI but not usable i.e. neither is the link opened nor the widget is getting focus.

Another issue is that the underscore (_) of the mnemonic is always rendered and not just when being activated via 'Alt' key.

Test Case:
1. go to Package Explorer
2. view menu > Top Level Elements > Working Sets
3. select a folder
4. context menu > Assign Working Sets...
Comment 1 Felipe Heidrich CLA 2009-05-19 10:22:47 EDT
*** Bug 276621 has been marked as a duplicate of this bug. ***
Comment 2 Markus Keller CLA 2009-09-14 14:59:12 EDT
Created attachment 147129 [details]
Fix

If you add a TraverseListener to the Link control, the 'doit' field also doesn't get set to true if the key matches the mnemonic character.

Here's a simple fix (first method copied from Label).
Comment 3 Felipe Heidrich CLA 2009-09-16 16:28:27 EDT
IMO, the code in Label doesn't make sense for Link.

A link is in the format: (atext link)* ptext?
for example: "&some text <a>a link</a> some text at the end"
In this case:
atext = &some text
link = a link
ptext = some text at the end
(atext link)* can repeat zero or more
ptext? can repeat zero or one

mnemonics in link and ptext are ignored.

when the mnemonic in the ith atext is hit, the ith link should receive focus.
Comment 4 Felipe Heidrich CLA 2009-09-16 16:29:58 EDT
Created attachment 147377 [details]
patch
Comment 5 Felipe Heidrich CLA 2009-09-21 10:42:17 EDT
Hi Markus, I released the patch in comment 4 which implements the behaviour described in comment 3. Let me know if that is useful to you.

Fixed in HEAD > 20090921
Comment 6 Markus Keller CLA 2009-10-06 08:33:58 EDT
> Hi Markus, I released the patch in comment 4 which implements the behaviour
> described in comment 3. Let me know if that is useful to you.

That's also fine for me, thx.
Comment 7 Dani Megert CLA 2009-10-28 06:06:12 EDT
Verified in I20091027-0100: mnemonics inside the link are now ignored.

I would still like to see the Javadoc of Link.setText(String) be more clear about this. Of course one can infer that a link does not have a mnemonic but a small additional comment would clarify this.
Comment 8 Felipe Heidrich CLA 2009-10-28 14:54:52 EDT
Adding this:

 * <p>
 * Mnemonics are indicated by an '&amp;' that causes the next
 * character to be the mnemonic. The receiver can have a    
 * mnemonic in the text preceding each link. When the user presses a
 * key sequence that matches the mnemonic, focus is assigned
 * to the link that follows the text. Mnemonics in links and in
 * the trailing text are ignored. On most platforms,
 * the mnemonic appears underlined but may be emphasised in a
 * platform specific manner.  The mnemonic indicator character
 * '&amp;' can be escaped by doubling it in the string, causing
 * a single '&amp;' to be displayed.
 * </p>
Comment 9 Dani Megert CLA 2009-10-29 03:56:31 EDT
Perfect! :-)