mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Added analyzer * WIP - Trying to create tests, failing with bad dependencies * Working test woo * Tidy up * Tidy up * Fix integration tests failing on command line * Use 4.11 compiler * Fix expecting 'e' as param name * Make analyzer come as part of Terminal.Gui * Add docs * Fix warnings
34 lines
779 B
Markdown
34 lines
779 B
Markdown
# TGUI001: Describe what your rule checks
|
|
|
|
**Category:** Reliability
|
|
**Severity:** Warning
|
|
**Enabled by default:** Yes
|
|
|
|
## Cause
|
|
|
|
When registering an event handler for `Accepting`, you should set Handled to true, this prevents other subsequent Views from responding to the same input event.
|
|
|
|
## Reason for rule
|
|
|
|
If you do not do this then you may see unpredictable behaviour such as clicking a Button resulting in another `IsDefault` button in the View also firing.
|
|
|
|
See:
|
|
|
|
- https://github.com/gui-cs/Terminal.Gui/issues/3913
|
|
- https://github.com/gui-cs/Terminal.Gui/issues/4170
|
|
|
|
## How to fix violations
|
|
|
|
Set Handled to `true` in your event handler
|
|
|
|
### Examples
|
|
|
|
```diff
|
|
var b = new Button();
|
|
b.Accepting += (s, e) =>
|
|
{
|
|
// Do something
|
|
|
|
+ e.Handled = true;
|
|
};
|
|
``` |