Skip to content
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

Show context menu on menu key press #3446

Merged
merged 3 commits into from
Nov 1, 2021

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Sep 4, 2021

Problem

Most keyboards have a key to open a context menu (mine requires pressing Fn+PrintScrn, but it's there). Currently this does nothing in CKAN, to the detriment of keyboard users.

Cause

The mod list context menu is implemented in the grid's MouseDown event, and pressing the menu key triggers KeyDown and does nothing.

Changes

Now the code to manage the menu is moved a new ShowModContextMenu function, which is called from MouseDown on a right click and KeyDown for Keys.Apps (the code for the menu key).

Similar changes are also made for the URL link labels in mod info and the About dialog, as well as the list of instances in the manage game instances dialog. And this key also now opens and closes the F10 menu in ConsoleUI.

Fixes #3445.

@HebaruSan HebaruSan added Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI Pull request labels Sep 4, 2021
@HebaruSan HebaruSan requested a review from DasSkelett September 4, 2021 22:09
@HebaruSan HebaruSan changed the title Show mod context menu on menu key press Show context menu on menu key press Sep 10, 2021
@HebaruSan HebaruSan added the ConsoleUI Issues affecting the interactive console UI label Sep 19, 2021
@DasSkelett
Copy link
Member

For some reason this isn't working for me, neither in the GUI nor the console UI, not when started through my IDE nor otherwise.
I've set a breakpoint in my IDE to check whether CKAN even receives the key press, and apparently it does, but with a KeyCode of None and basically everything else unset.

e = KeyEventArgs
 base = EventArgs
 Alt = {bool} false
 Control = {bool} false
 Handled = {bool} false
 KeyCode = {Keys} None
 KeyData = {Keys} None
 KeyValue = {int} 0
 Modifiers = {Keys} None
 Shift = {bool} false
 SuppressKeyPress = {bool} false
 event_handled = {bool} false
 key_data = {Keys} None
 supress_key_press = {bool} false

In other applications like Firefox or Dolphin or other KDE windows it works fine.
Given that there is no useful information to get from the KeyEventArgs, I don't see a way to fix this on our side.

I blame some misconfiguration of my system or KDE not handling it correctly.
@Xetaxheb already tested for us on Windows, so I'm fine moving on as is.

@HebaruSan HebaruSan merged commit 2564dfb into KSP-CKAN:master Nov 1, 2021
@HebaruSan HebaruSan deleted the fix/gui-menu-key branch November 1, 2021 14:50
@HebaruSan
Copy link
Member Author

HebaruSan commented Nov 3, 2021

For some reason this isn't working for me, neither in the GUI nor the console UI, not when started through my IDE nor otherwise.

Hmm, I'm seeing the same thing now in GNOME Shell, including the same null values for KeyCode, KeyData, and KeyValue.

I blame some misconfiguration of my system or KDE not handling it correctly. @Xetaxheb already tested for us on Windows, so I'm fine moving on as is.

I developed this in Windows, too. I'm guessing Mono has a problem handling this key.

@HebaruSan
Copy link
Member Author

Confirmed Mono bug (or something more complicated); this function receives keycode 135 and returns 0:

https://github.com/mono/mono/blob/5eb240a7fd5a1fee02a3851ccacca0925563258a/mcs/class/System.Windows.Forms/System.Windows.Forms/X11Keyboard.cs#L680-L697

The LookupString call seems to work based on my debugging output:

ks = XK_Menu, keysym = 65383

... but then the keyc2vkey lookup apparently doesn't have something usable for this key. I think that array is built by examining the X11 keyboard configuration, may take a while to get through it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended ConsoleUI Issues affecting the interactive console UI Easy This is easy to fix GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Menu key does not work on mods list (accessibility)
2 participants