Skip to content

Temporary way to display keyboard shortcuts on button tooltips#1432

Merged
cameronwhite merged 4 commits into
PintaProject:masterfrom
Lehonti:improvement3
May 10, 2025
Merged

Temporary way to display keyboard shortcuts on button tooltips#1432
cameronwhite merged 4 commits into
PintaProject:masterfrom
Lehonti:improvement3

Conversation

@Lehonti

@Lehonti Lehonti commented May 9, 2025

Copy link
Copy Markdown
Contributor

A further step towards realizing #1408

A more readable representation of the keyboard shortcuts would require a more refined approach.

For a future pull request, I propose creating a KeyCombination struct that contains the key and the modifiers only, and is easy to create and convert to the strings that Gtk needs and to human-readable strings, and have Command store that instead of what it is storing now.

@cameronwhite

Copy link
Copy Markdown
Member

Thanks, the changes here look good.
I'm not sure if the KeyCombination suggestion is going to make things simpler? I think all we need is just a variant of CtrlLabel () to produce the label for a shortcut, which seems pretty straightforward

@Lehonti

Lehonti commented May 10, 2025

Copy link
Copy Markdown
Contributor Author

You are right @cameronwhite . I am not that acquainted with Gtk, so I was not aware of what Gtk.Functions.AcceleratorGetLabel did until I looked at CtrlLabel.

I could do what you suggest. The main issue is getting hold of a SystemManager (for deciding if we want <Meta> or <Control>), which unfortunately requires changes in many files to do properly, but I could introduce a PintaCore reference and get rid of it in a future pull request. Or I could leave it as <Primary> for now. Update: see below.

@Lehonti

Lehonti commented May 10, 2025

Copy link
Copy Markdown
Contributor Author

I just did what you suggested @cameronwhite. The function Gtk.Functions.AcceleratorGetLabel shows the key combinations in a readable way, and it converts the <Primary> key to the right one for the OS in question (at least from what I could see by testing my changes on Ubuntu, namely, showing the primary key as 'Ctrl').

@cameronwhite

Copy link
Copy Markdown
Member

I think we do need translate the <Primary> modifier to have it work on macOS, otherwise it shows up as Ctrl when it should be Cmd

Screenshot 2025-05-10 at 3 51 54 PM
Screenshot 2025-05-10 at 3 52 23 PM

SystemManager.GetOperatingSystem() is static though so I don't think that's a big problem to introduce the reference

@Lehonti

Lehonti commented May 10, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @cameronwhite for testing it on your machine. I've now applied your suggestion. Could you test again and confirm if it works?

@cameronwhite

Copy link
Copy Markdown
Member

Yep, that looks good now on Mac!

@cameronwhite cameronwhite linked an issue May 10, 2025 that may be closed by this pull request
@cameronwhite cameronwhite merged commit 3cda56e into PintaProject:master May 10, 2025
@Lehonti Lehonti deleted the improvement3 branch May 10, 2025 20:23
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

Successfully merging this pull request may close these issues.

Show keyboard shortcut on button tooltip

2 participants