Terminal.Gui
Terminal.Gui copied to clipboard
Need a way to cancel `InvokeCommand`
As a user of a View that defines a command, e.g. with AddCommand (Command.Accept, OnAccept);, I sometimes want to prevent the command from being executed.
AddCommand etc... are private, so I can't remove the command binding.
View.OnAccept is not virtual, so I can't override it.
The View.Accept event invokes subscribers in a non-deterministic way, so I can't subscribe can do e.Cancel = true.
I think what I want is:
view.InvokingCommand += (s, e) => { e.Cancel = true; }
Or something.
Ideally, it should use a CancellationToken, so others can react accordingly.