Skip to content

Commit 3ae3921

Browse files
committed
2 parents 26a08ad + 7e6a092 commit 3ae3921

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,25 @@ The biggest strength of this approach is that you decide what is the order of co
311311

312312
## Mouse
313313

314-
Currently this library does not support mouse input.
314+
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.
315+
316+
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).
317+
318+
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:
319+
320+
```csharp
321+
private static void ProcessMouseEvent(in MouseRecord mouseEvent)
322+
{
323+
ConsoleManager.MousePosition = new Position(mouseEvent.MousePosition.X, mouseEvent.MousePosition.Y);
324+
ConsoleManager.MouseDown = (mouseEvent.ButtonState & 0x0001) != 0;
325+
}
326+
```
327+
328+
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.
329+
330+
<p align="center">
331+
<img src="https://raw.githubusercontent.com/TomaszRewak/C-sharp-console-gui-framework/master/Resources/input%20example.gif" width=350/>
332+
</p>
315333

316334
## Performance
317335

0 commit comments

Comments
 (0)