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

KeyDown and KeyUp event support #371

Closed
wants to merge 8 commits into from
Closed

KeyDown and KeyUp event support #371

wants to merge 8 commits into from

Conversation

tig
Copy link
Collaborator

@tig tig commented Apr 15, 2020

For an enhancement to MenuBar I'm working on I need access to alt key down events.

I discussed it a bit here: #366

This pull request delivers that in a generic/flexible way.

The essence is a set of new virtual members on Responder:

public virtual bool KeyDown (KeyEvent keyEvent)
public virtual bool KeyUp (KeyEvent keyEvent)

Then on View a set of overrides of those virtuals plus convenient Actions:

public Action<KeyEvent> OnKeyDown;
public Action<KeyEvent> OnKeyDown;

Users can then either implement KeyDown or KeyUp in derived classes, or use the Actions for objects they hold:

win.OnKeyDown += (KeyEvent keyEvent) => ...

demo.cs has been updated with a simple demo.

Caveat: It appears that only the WindowsDriver is actually capable of capturing and sending distinct key up and key down events. I studied both CursesDriver and NetDriver and couldn't find any evidence that they are capable of sourcing these events. I would love to be proven wrong. Regardless, the design of this PR means that apps that choose to utilize these events will need to do so understanding that the won't get them anywhere but on Windows.

@migueldeicaza
Copy link
Collaborator

I think this looks good, will merge soon. Will have to do by hand as there are a lot of white space changes

@tig
Copy link
Collaborator Author

tig commented Apr 19, 2020

Looks like you took care of this already.

@tig tig closed this Apr 19, 2020
@tig tig deleted the key_down_up branch April 19, 2020 14:27
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