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

Added the ability to customize keyboard shortcuts. Fix for: #92 and #13 #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

QuantMad
Copy link

Full customization of keyboard shortcuts. There are plans to add the ability to create custom keyboard shortcuts (such as launching other applications)

@bk138
Copy link
Owner

bk138 commented Aug 24, 2022

Thanks for the PR! Can you give an intro to the general architecture of this please?

try {
x /= instance.mScaling;
y /= instance.mScaling;
/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to not indent code that's not being changed. This makes reviewing changes very hard :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I'm really sorry. I've never made a pull request before. This seems a bit tricky. I can pull the latest version, make my edits where needed, and repeat the pull-request. Will it save the situation?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies in advance for my English. I rely a lot on Google translator.
I don't know if my approach is architecturally correct, but here's what it is:
There is a VNCKey enumeration, each member of which corresponds to a keysym, and has one parameter that is responsible for the current state of the key (pressed / released). The onKeyEvent event of the InputService passes the corresponding key (if it was defined in the enum) a new status. Thus, at any point in the program, when accessing the button, you can find out its current state.
Hotkey processing also has a fairly simple principle: There is a small "HotkeyBinding" class, which includes an array of three VNCKeys, and a stub for anonymous classes implemented on the basis of the ICommand interface. This interface has only one method: void execute();, which is responsible for what exactly this keyboard shortcut does. Further, the matter is small: in the InputService, you can add any key combination to the static constant HOTKEY_BINDINGS by writing a couple of lines.

As for the user interface, the code looks scary, but it works. All shortcuts are added to the user interface dynamically, and do not require any intervention in the process. The programmer just needs to add a new line to the HOTKEY_BINDINGS constant, and he does not have to worry about everything else. That was the idea

…F12 in the GUI. Added hotkeys: Power dialog, Notifications and Split screen
@QuantMad QuantMad requested a review from bk138 August 24, 2022 20:16
@bk138
Copy link
Owner

bk138 commented Aug 30, 2022

Hi @QuantMad I'm currently quite busy with $$$-work, so expect this to wait a bit.

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.

2 participants