Elius94 / console-gui-tools

A simple library to draw option menu or other popup inputs and layout on Node.js console.
MIT License
106 stars 17 forks source link

Will be enabled the mouse in the future? #43

Closed jrcribb closed 1 year ago

jrcribb commented 1 year ago

Hi, excelent work. I'va a question: Will be enabled the mouse in the future?

Elius94 commented 1 year ago

Thanks a lot Jorge :) Mouse click is on the todo list but I think that it will be so hard to do. That's because there's no Node.js terminal mouse click channel input. Please, feel free to figure it out and maybe fire a PR on this repo. Thanks a lot.

Elius94 commented 1 year ago

Hi! I tried this thing and it's working on Linux bash (on windows it only works running node in a WSL shell).

https://github.com/TooTallNate/keypress

I can integrate this but I prefere to find a way to make it works also on windows firs.

Elius94 commented 1 year ago

Hi, I'm starting to develop this feature on this branch: https://github.com/Elius94/console-gui-tools/tree/Elius94/issue43

Elius94 commented 1 year ago

Changed the mouse terminal protocol to SGR Now mouse evets are captured and managed in the ConsoleManager class. the event is fired by MouseManager Instance: event name: mouseevent event data:


export interface MouseEventArgs {
shift: boolean;
alt: boolean;
ctrl: boolean;
// , pressed: pressed
x: number;
y: number;
code: number;
left: boolean;
right: boolean;
xFrom: number | null;
yFrom: number | null;
}

export interface MouseEvent { name: string; eaten: number; data: MouseEventArgs; }



##TODO:
- Propagate this event to the widget.
- Make them able to manage theese kind of events:
 - Drag boxes
 - Click on buttons
 - Scroll up and down (with click and wheel)

## Screenshot:
![mouse](https://user-images.githubusercontent.com/14907987/201684794-5897f2b0-386b-4066-bfdb-5d3fba9f58e3.gif)