bugGNU Octave - Bugs: bug #60869, Ampersand character in uimenu label

 
 

bug #60869: Ampersand character in uimenu label

Submitter:  Guillaume <gyom>
Submitted:  Thu 01 Jul 2021 03:55:25 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Wont Fix Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 27 Jul 2021 03:15:57 AM UTC, comment #5: 

I've looked at this and I think it is easier to just use the conventions that Qt implements:

1) A single '&' character makes the following character a shortcut key and the '&' character itself is consumed.

2) The two-character sequence "&&" is converted to the single character '&'.

Hence, if the desired label is "A & B" then write "A && B".  This code will work in Matlab or Octave.  The sequences "A&& B" and "A&&B" are Matlab-specific.

Rik <rik5>
Group administrator
Fri 02 Jul 2021 04:52:21 PM UTC, comment #4: 

Thanks for testing.

For the second set of results, I think they are using the convention that doubling a special character stops it from being special.  In strings, for example, doubling the single quote character just renders one quote character.


x = 'don''t'
x = don't


But, I also agree that this doesn't mean the interpreter should also add spaces.

Rik <rik5>
Group administrator
Fri 02 Jul 2021 02:34:39 PM UTC, comment #3: 

For your two examples, I get:
'A&B'   -> 'AB_' (underscore B)
'A&\tB' -> 'A&B'

Furthermore:
'A&& B' -> 'A & B'
'A&&B'  -> 'A & B'
'A& B'  -> 'A& B'

The space added before '&' in the last examples puzzles me.

Guillaume <gyom>
Thu 01 Jul 2021 08:48:43 PM UTC, comment #2: 

Confirmed.

Can you determine exactly which conditions generate a keyboard shortcut?  For example, does the '&' character have to be preceded by whitespace as well?


H = figure;
uimenu (H, 'Label', 'A&B');


Is the Label that is displayed 'A&B' or 'AB' with 'B' being a keyboard shortcut?

Also, is it any whitespace that stops interpretation of the ampersand as a shortcut?


H = figure;
uimenu (H, 'Label', sprintf ('A&\tB'));


Is the label 'A& B' or does Matlab make a Tab the shortcut key?

Rik <rik5>
Group administrator
Thu 01 Jul 2021 03:56:57 PM UTC, comment #1: 

Apologies. Use "Label" instead of "Text" (I open another bug report for this):


H = figure ();
uimenu (H, "Label", "A & B");
uimenu (H, "Label", "A &B");


Guillaume <gyom>
Thu 01 Jul 2021 03:55:25 PM UTC, original submission:  

The ampersand character in the text of a label is used to specify mnemonic keyboard shortcut. In Matlab, if the character that follows is a space, this is disabled and the ampersand character is instead displayed. Screenshot attached showing the difference between Matlab and Octave.


H = figure ();
uimenu (H, "Text", "A & B");
uimenu (H, "Text", "A &B");


Guillaume <gyom>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #51635:  uimenu.png added by gyom (15KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-07-30 rik5 StatusConfirmed Wont Fix
        Open/ClosedOpen Closed
    2021-07-01 rik5 Priority5 - Normal 3 - Low
        StatusNone Confirmed
    2021-07-01 gyom Attached File- Added uimenu.png, #51635

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code