bugGNU TeXmacs - Bugs: bug #60756, Ampersand in the menu

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #60756: Ampersand in the menu

Submitter:  Pavel Panteleev <panpav>
Submitted:  Wed 09 Jun 2021 04:41:11 PM UTC
   
 
Category:  Qt port Priority:  3 - Low
Item Group:  Error Status:  Postponed
Privacy:  Public Assigned to:  mgubi
Originator Name:  Open/Closed:  Open
Release:  None Release:  1.99.21
Fixed Release:  None Fixed Release: 
Keywords: 

Sun 06 Nov 2022 04:15:40 PM UTC, comment #3: 

There is no way to escape "&".

Here is my hack to show the key (it only works when & is the ending key):


diff --git a/src/Plugins/Qt/qt_utilities.cpp b/src/Plugins/Qt/qt_utilities.cpp
index 706c1d7..d25a502 100644
--- a/src/Plugins/Qt/qt_utilities.cpp
+++ b/src/Plugins/Qt/qt_utilities.cpp
@@ -203,6 +203,10 @@ to_qkeysequence (string ks) {
              << qks.toString (QKeySequence::NativeText).toLatin1().data() << LF;
     return qks;
   }
+  if (ends (r, "&")) {
+    // HACK: because Qt menu can not show the key &
+    r= r(0, N(r)-1) * "Shift+7";
+  }
   return QKeySequence (to_qstring (r));
 }


comment #2:

> comment #1:
> > Yes, this an annoying known problem, due to Qt.
> > It seems that there is no way to escape the ampersand.
> >
>
> It seems that there is a way to avoid this. You just need to use && to escape the ampersand in the menu.
>
> https://stackoverflow.com/questions/46580519/how-to-insert-a-special-character-into-qmenu-as-a-part-of-title-text/46580776
>
> https://doc.qt.io/qt-5/qmenubar.html#details
> "The ampersand in the menu item's text sets Alt+F as a shortcut for this menu. (You can use "&&" to get a real ampersand in the menu bar.)"

Darcy Shen <sadhen>
Group Member
Wed 23 Jun 2021 11:44:29 AM UTC, comment #2: 

comment #1:

> Yes, this an annoying known problem, due to Qt.
> It seems that there is no way to escape the ampersand.
>


It seems that there is a way to avoid this. You just need to use && to escape the ampersand in the menu.

https://stackoverflow.com/questions/46580519/how-to-insert-a-special-character-into-qmenu-as-a-part-of-title-text/46580776

https://doc.qt.io/qt-5/qmenubar.html#details
"The ampersand in the menu item's text sets Alt+F as a shortcut for this menu. (You can use "&&" to get a real ampersand in the menu bar.)"

Pavel Panteleev <panpav>
Sun 20 Jun 2021 07:48:39 PM UTC, comment #1: 

Yes, this an annoying known problem, due to Qt.
It seems that there is no way to escape the ampersand.

Joris van der Hoeven <vdhoeven>
Group administrator
Wed 09 Jun 2021 04:41:11 PM UTC, original submission:  

On many platforms, the symbol “&” in the menu bar has a special meaning:

https://stackoverflow.com/questions/26791102/qt-use-of-in-tr 1

It seems that this special meaning is not taken into account when this symbol appears in TeXmacs menus.

Details and possible workarounds on the forum (problem 2):
http://forum.texmacs.cn/t/some-known-problems-on-windows/468

Pavel Panteleev <panpav>

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by sadhen (Posted a comment)
  • -email is unavailable- added by vdhoeven (Posted a comment)
  • -email is unavailable- added by panpav (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.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-06-20 vdhoeven CategoryWindows port Qt port
    2021-06-20 vdhoeven Priority5 - Normal 3 - Low
        StatusNone Postponed
        Assigned toNone mgubi

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code