Skip to content

Commit ce28202

Browse files
authored
[222_60] Correct macOS modifier symbols in accent shortcut tooltips (#2982)
1 parent 95806e9 commit ce28202

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

devel/222_60.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# #2962 There is a problem with the display of accent shortcut keys on macOS
2+
3+
## Problem
4+
On macOS, modifier keys in accent shortcut tooltips (e.g., in the math toolbar) were displayed incorrectly instead of the corresponding macOS modifier symbols (⌘, ⌥, ⇧)
5+
6+
## Solution
7+
8+
This patch ensures that modifier symbols are correctly rendered in Qt tooltips on macOS through two small adjustments:
9+
10+
### 1. Tooltip UTF-8 Conversion
11+
In `src/Plugins/Qt/qt_ui_element.cpp`, tooltip text is now passed through `cork_to_utf8()` before being converted to a Qt string. This converts TeXmacs character references into their proper Unicode symbols so that Qt displays them correctly.
12+
13+
### 2. macOS Shortcut Rendering Condition
14+
In `src/Texmacs/Server/tm_config.cpp`, the `kbd_system_prevails` condition was refined to avoid applying legacy modifier substitutions when macOS fonts are already being used. This prevents conflicts with the font-based rendering of macOS modifier symbols.
15+
16+
## Result
17+
Accent shortcut tooltips on macOS now correctly display modifier keys using the expected symbols (⌘, ⌥, ⇧).

src/Plugins/Qt/qt_ui_element.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qt_window_widget.hpp"
2020

2121
#include "analyze.hpp"
22+
#include "converter.hpp"
2223
#include "message.hpp"
2324
#include "promise.hpp"
2425
#include "scheme.hpp"
@@ -513,7 +514,7 @@ qt_ui_element_rep::as_qaction () {
513514
{
514515
typedef quartet<string, int, color, bool> T1;
515516
T1 y= open_box<T1> (get_payload (help, text_widget));
516-
act->setToolTip (to_qstring (y.x1));
517+
act->setToolTip (to_qstring (cork_to_utf8 (y.x1)));
517518
// HACK: force displaying of the tooltip (needed for items in the
518519
// QMenuBar)
519520
QObject::connect (act, SIGNAL (hovered ()), act, SLOT (showToolTip ()));
@@ -929,7 +930,7 @@ qt_ui_element_rep::as_qwidget () {
929930
typedef quartet<string, int, color, bool> T1;
930931
T1 y= open_box<T1> (get_payload (help, text_widget));
931932
QWidget* w= qtw->as_qwidget ();
932-
w->setToolTip (to_qstring (y.x1));
933+
w->setToolTip (to_qstring (cork_to_utf8 (y.x1)));
933934
qwid= w;
934935
} break;
935936

src/Texmacs/Server/tm_config.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ kbd_render (tree t) {
328328
static string
329329
kbd_system_prevails (string s) {
330330
string laf= get_preference ("look and feel");
331-
bool mac= os_macos () && (laf == "default" || laf == "macos");
331+
bool mac= os_macos () && (laf == "default" || laf == "macos") &&
332+
!use_macos_fonts ();
332333
if (mac && starts (s, "A-")) {
333334
string ss= s (2, N (s));
334335
string r = "escape " * ss;

0 commit comments

Comments
 (0)