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

Proof of concept: add support for opt-in inside-out keyboard event propagation #968

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GiGurra
Copy link

@GiGurra GiGurra commented Apr 19, 2024

At present, it is not possible to (unless resorting to very unorthodox hacks) create inside-out event handler chains for keyboard events. This is useful in many applications (I ran into this with my first tview application), and is the default in the web world.

This PR is intended as a proof-of-concept rather than something to merge in its current form. Maybe there are better ways of solving this?

This PR creates an option where a user can opt-in to create inside out keyboard event propagation, by adding an additional captureFunctionAfter. The default such function just captures all events (to preserve tview's current semantics), but you can override this to add your own logic, filter out some for passing back to parents etc.

In order for this to be possible, a bool return value of the InputHandler() and WrapInputHandler functions indicating event consumption was added.

Existing widget/primitive specific input handlers have not been given any event consumption semantics, as that would change tview's semantic overall, plus different applications may wish to customize this, so consuming inside the default input handlers would (I suspect) break tons of applications.

This PR is perhaps more of a proof of concept than a finished solution - I'd just like to get the discussion going (and hopefully, if this PR or a variant of it, in the future gets merged I can remove my incredibly ugly hacks to emulate this i my own apps :))

Perhaps there are better ways of doing this? The base idea is - I really think tview would be a lot easier in many situations if inside-out event propagation was possible - if that comes in this form of a PR like mine, or totally different impl doesn't matter that much to me

…sing, allowing for opt-in inside out even propagation
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.

None yet

1 participant