mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Rename SwipeGestureRecognizer to SwipeGestureHandler
The origin of this proposal is the name of the `swipe-left`, etc. directional, boolean properties. They're missing another verb in their name. In principle the right choice would be "recognize". That is what the type name suggests, that's the term the documentation uses, so the code should read `recognize-swipe-left: true;`. However that is a long word. "Handle" is a verb that's simpler. It's also more generic (that's a downside), but it's otherwise short enough to make things look "right": ``` SwipeGestureHandler { handle-swipe-left: true; swiped => { something.naviate-left(); } } ``` Therefore this patch proposes to rename the type to SwipeGestureHandler and prefixes the boolean directional properties with "handle".
This commit is contained in:
parent
0e751b1eea
commit
cd2b738c7a
9 changed files with 107 additions and 84 deletions
|
@ -657,21 +657,20 @@ export component Example inherits Window {
|
|||
}
|
||||
```
|
||||
|
||||
## `SwipeGestureRecognizer`
|
||||
## `SwipeGestureHandler`
|
||||
|
||||
Use the `SwipeGestureRecognizer` to react to swipes gesture in some particular direction. Recognition is limited to the element's geometry.
|
||||
Use the `SwipeGestureHandler` to handle swipe gesture in some particular direction. Recognition is limited to the element's geometry.
|
||||
|
||||
Specify the different swipe directions you'd like to recognise by setting the `swipe-left/right/up/down` properties and react to the gesture in the `swiped` callback.
|
||||
Specify the different swipe directions you'd like to handle by setting the `handle-swipe-left/right/up/down` properties and react to the gesture in the `swiped` callback.
|
||||
|
||||
Pointer press events on the recognizer's area are forwarded to the children with a small delay.
|
||||
If the pointer moves by more than 8 logical pixels in one of the enabled swipe directions, the gesture is recognized, and events are no longer forwarded to the children.
|
||||
|
||||
### Properties
|
||||
|
||||
- **`enabled`** (_in_ _bool_): When disabled, the `SwipeGestureRecognizer` doesn't recognize any gestures.
|
||||
- **`enabled`** (_in_ _bool_): When disabled, the `SwipeGestureHandler` doesn't recognize any gestures.
|
||||
(default value: `true`)
|
||||
- **`swipe-left`**, **`swipe-right`**, **`swipe-up`**, **`swipe-down`** (_out_ _bool_): Enable recognition of swipes in
|
||||
the corresponding direction. (default value: `false`)
|
||||
- **`handle-swipe-left`**, **`handle-swipe-right`**, **`handle-swipe-up`**, **`handle-swipe-down`** (_out_ _bool_): Enable handling of swipes in the corresponding direction. (default value: `false`)
|
||||
- **`pressed-position`** (_out_ _Point_): The position of the pointer when the swipe started.
|
||||
- **`current-position`** (_out_ _Point_): The current pointer position.
|
||||
- **`swiping`** (_out_ _bool_): `true` while the gesture is recognized, false otherwise.
|
||||
|
@ -697,9 +696,9 @@ export component Example inherits Window {
|
|||
|
||||
property <int> current-page: 0;
|
||||
|
||||
sgr := SwipeGestureRecognizer {
|
||||
swipe-right: current-page > 0;
|
||||
swipe-left: current-page < 5;
|
||||
sgr := SwipeGestureHandler {
|
||||
handle-swipe-right: current-page > 0;
|
||||
handle-swipe-left: current-page < 5;
|
||||
swiped => {
|
||||
if self.current-position.x > self.pressed-position.x + self.width / 4 {
|
||||
current-page -= 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue