Replies: 4 comments 3 replies
-
This was always my opinion too. It's wrong to invoke a clicked event in these situations, but only mouse down and mouse up (pressed/release). |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Ok super prototype click selecting is in place |
Beta Was this translation helpful? Give feedback.
-
Ok here is the MouseInterpreter as implemented in #3837 I've renamed narrative MouseButtonSequence instead as it is clearer. A sequence accumulates events then conditionally resolves them into a single 'resolved' event. Similarly to For example:
Would result in a click. Likewise
Would result in nothing because the mouse is moving around - its clearly a click and drag not a click. Its not fully implemented but it will be:
For now the input and output objects for this subsystem are MouseEventArgs because that is what everything else in Terminal.Gui is dealing in. I dont want to tackle that beast just yet. Benefits over current system
|
Beta Was this translation helpful? Give feedback.
-
User expectation
Users interact with computers via mouse. We want to make the experience as smooth as in GUI environments e.g. Windows. We also want the programmer making the app to have a good experience.
So events like clicked, double and click-drag should be easy to hook without having to think too hard.
But lets look at some advanced scenarios:
User clicks down in
User clicks down wobbles then releases
Here is two examples of that, in the first case user waits too long before release so UI does not close. In second case the gap is shorter so behaviour is treated as click.
To support this we need to gather and retain information about what the mouse is doing as long as any mouse button is down - and for a short time afterwards, before relasing certain events e.g. click.
The Console
The console communicates mouse state to us via ANSI escape sequences:
ESC[<C;X;YM
C indicates button
X/Y indicates coordinates
M or m is terminator and indicates press/release
0
1
32
35
* this is my understanding currently, it may be slightly off as I'm not an expert yet.
A futureproof mouse model
I think we can separate the ANSI layer, the state (interpretation) and the library user facing layers:
For each button we need a class to model its state at any given in time (current or past):
But we also need to be able to accumulate these between when a mouse is clicked down and when it is released. We could store all states or just the first and last. So far I am considering the word Narrative i.e. we are telling a story about what the mouse did while the button was pressed.
This is my initial sketch of the class:
There is a timing element and decision engine that must interpret clicks and must have regular 'check ins' regardless of whether there are more mouse actions.
For example imagine we get a click
We must wait a short time to see if there is another click, if so then we need to accumulate that in the narrative and release it as a double click (assuming no third click).
We need to make sure not to release click then double click then tripple click.
Here is my initial pseudocode WIP on the topic:
Beta Was this translation helpful? Give feedback.
All reactions