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

Allow Application.RootMouseEvent to cancel events #2096

Closed
tznind opened this issue Oct 18, 2022 · 0 comments · Fixed by #2100
Closed

Allow Application.RootMouseEvent to cancel events #2096

tznind opened this issue Oct 18, 2022 · 0 comments · Fixed by #2100

Comments

@tznind
Copy link
Collaborator

tznind commented Oct 18, 2022

Is your feature request related to a problem? Please describe.
There are 2 global 'pre' handlers that fire before events get passed to any Views. These are:

  • Application.RootKeyEvent
  • Application.RootMouseEvent

RootKeyEvent is a Func<KeyEvent,bool> which allows callback to return true to cancel the event. But RootMouseEvent is Action<MouseEvent> and there is no Handled property on MouseEvent for cancelling (or any other way I could see to cancel).

My primary use case for cancellation is in TerminalGuiDesigner where you don't want right clicking in controls such as TextField to throw up the context menu - Instead the designer wants to show its own context menu and suppress right click events).

Also for consistency with RootKeyEvent.

Also handy if events are being misreported in an environment e.g. like #1617 . A developer could add a global event handler that turned off the mouse completely by just returning true.

Describe the solution you'd like
Change RootMouseEvent to Func<MouseEvent,bool> so that it works like keyboard one.

The code change to achieve this is quite small but it is a breaking change for anyone subscribing to this event. The current docs for this event are:

/// <summary>
/// Merely a debugging aid to see the raw mouse events
/// </summary>
public static Action<MouseEvent> RootMouseEvent;

So I don't think there will be that many users of this bit of the system so the breakage is limited.

@tig tig added enhancement breaking-change For PRs that introduces a breaking change (behavior or API) labels Oct 18, 2022
@tig tig removed the breaking-change For PRs that introduces a breaking change (behavior or API) label Oct 19, 2022
@tig tig closed this as completed in #2100 Oct 19, 2022
tig added a commit that referenced this issue Oct 19, 2022
Fixes #2096. Makes RootMouseEvent cancellable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants