Skip to content

Commit

Permalink
MouseClick: Split mouse click when <on>begin-and-end</on>
Browse files Browse the repository at this point in the history
When the `begin-and-end` option is used, the mouse button is down when
the gesture begins and up when the gesture ends.
  • Loading branch information
JoseExposito committed Dec 1, 2024
1 parent 2abfa7e commit f71c321
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,8 @@ Options:
| button | `1`/`2`/`3`/`8`/`9` | Left click (1), middle click (2), right click (3), back button (8) or forward button (9) |
| on | `begin`/`end`/`begin-and-end` | If the mouse click should be executed on the beginning and/or on the end of the gesture. |

When the `begin-and-end` option is used, the mouse button is down when the gesture begins and up when the gesture ends.

Example:

```xml
Expand Down
10 changes: 8 additions & 2 deletions src/actions/mouse-click.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,21 @@ void MouseClick::onGestureBegin(const Gesture& /*gesture*/) {

if (shouldExecuteAction(ExecuteActionOn::BEGIN, this->executeActionOn)) {
this->windowSystem.sendMouseDown(this->button);
this->windowSystem.sendMouseUp(this->button);

if (this->executeActionOn != ExecuteActionOn::BEGIN_AND_END) {
this->windowSystem.sendMouseUp(this->button);
}
}
}

void MouseClick::onGestureUpdate(const Gesture& /*gesture*/) {}

void MouseClick::onGestureEnd(const Gesture& /*gesture*/) {
if (shouldExecuteAction(ExecuteActionOn::END, this->executeActionOn)) {
this->windowSystem.sendMouseDown(this->button);
if (this->executeActionOn != ExecuteActionOn::BEGIN_AND_END) {
this->windowSystem.sendMouseDown(this->button);
}

this->windowSystem.sendMouseUp(this->button);
}
}

0 comments on commit f71c321

Please sign in to comment.