Skip to content

Impossible to display "Del" and "Insert" as MenuItem accelerator #1852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
guiv42 opened this issue Feb 24, 2025 · 3 comments
Open

Impossible to display "Del" and "Insert" as MenuItem accelerator #1852

guiv42 opened this issue Feb 24, 2025 · 3 comments

Comments

@guiv42
Copy link

guiv42 commented Feb 24, 2025

Describe the bug
In a Linux app, I'm using "Del" and "Insert" keys as accelerators for some menu items, and there's no way to have these keys displayed.

To Reproduce
Call org.eclipse.swt.widgets.MenuItem.setText(), with menu item text and accelerator separated by "\t" character as described in the documentation.

Expected behavior
In menu item, accelerator is displayed (right-aligned) next to menu item text.
E.g. it works normally for a simple accelerator like "X", but it cannot work with "Del" or "Insert" keys

Screenshots
None

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS

note: I did not check on other platforms, problem may be present as well.

  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    tested on Linux openSuse tumbleweed

  2. JRE/JDK version
    java-21-openjdk

Version since
Reproduced with SWT version 4.26.
Issue is still present in most recent code base when writing this (see analysis below)

Workaround (or) Additional context
Analysis of the current implementation, the only valid strings for an accelerator in a menu item are:

And "Del" and "Insert" key do not match these patterns, so such accelerators cannot be displayed.
I did not test explicitly, but issue should also be present for other keys (e.g. "Esc")

@tmssngr
Copy link
Contributor

tmssngr commented May 14, 2025

Yes, this is a problem since years.

@guiv42
Copy link
Author

guiv42 commented May 14, 2025

Thank you for your answer.
Just a naive question: would it be possible to add a few more "if" statements with a few keys (Insert/Del/Esc/...), just like it is done currently with "Enter"?
Current code:

	if ("Enter".equals(text.substring(start))) {
		maskKeysym.keysym = GDK.GDK_ISO_Enter;
	}

Hypothesis :

	if ("Insert".equals(text.substring(start))) {
		maskKeysym.keysym = GDK.GDK_Insert;    // or GDK.GDK_KP_Insert ?
	}

I admit that a comparison with a hard-coded string is not ideal, but could that be a workaround?

tmssngr added a commit to syntevo/eclipse.platform.swt that referenced this issue May 21, 2025
tmssngr pushed a commit to syntevo/eclipse.platform.swt that referenced this issue May 21, 2025
@tmssngr
Copy link
Contributor

tmssngr commented May 21, 2025

@guiv42 Your investigation was right. I've added more words and they work on my test system.

tmssngr pushed a commit to syntevo/eclipse.platform.swt that referenced this issue May 21, 2025
tmssngr pushed a commit to syntevo/eclipse.platform.swt that referenced this issue May 21, 2025
tmssngr pushed a commit to syntevo/eclipse.platform.swt that referenced this issue May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants