Struct rute::auto::wheel_event::WheelEvent
source · pub struct WheelEvent<'a> { /* private fields */ }
Expand description
Notice these docs are heavy WIP and not very relevent yet
Wheel events are sent to the widget under the mouse cursor, but if that widget does not handle the event they are sent to the focus widget. Wheel events are generated for both mouse wheels and trackpad scroll gestures. There are two ways to read the wheel event delta: angleDelta() returns the delta in wheel degrees. This value is always provided. pixelDelta() returns the delta in screen pixels and is available on platforms that have high-resolution trackpads, such as MacOS . If that is the case, source() will return Qt::MouseEventSynthesizedBySystem.
The functions pos() and globalPos() return the mouse cursor’s location at the time of the event.
A wheel event contains a special accept flag that indicates whether the receiver wants the event. You should call ignore() if you do not handle the wheel event; this ensures that it will be sent to the parent widget.
The QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.
The event handler QWidget::wheelEvent() receives wheel events.
See also: MouseEvent
Widget::grab_mouse
Licence
The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Implementations
sourceimpl<'a> WheelEvent<'a>
impl<'a> WheelEvent<'a>
sourcepub fn pixel_delta(&self) -> Point<'_>
pub fn pixel_delta(&self) -> Point<'_>
Returns the scrolling distance in pixels on screen. This value is provided on platforms that support high-resolution pixel-based delta values, such as MacOS . The value should be used directly to scroll content on screen.
Example:
Note: On platforms that support scrolling phases , the delta may be null when:
- scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
- or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). Note: On X11 this value is driver specific and unreliable, use angleDelta() instead
sourcepub fn angle_delta(&self) -> Point<'_>
pub fn angle_delta(&self) -> Point<'_>
Returns the distance that the wheel is rotated, in eighths of a degree. A positive value indicates that the wheel was rotated forwards away from the user; a negative value indicates that the wheel was rotated backwards toward the user.
Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
However, some mice have finer-resolution wheels and send delta values that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can partially scroll the widget in response to each wheel event.
Example:
Note: On platforms that support scrolling phases , the delta may be null when:
- scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
- or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
sourcepub fn delta(&self) -> i32
pub fn delta(&self) -> i32
This function has been deprecated, use pixelDelta() or angleDelta() instead.
sourcepub fn orientation(&self) -> Orientation
pub fn orientation(&self) -> Orientation
Returns the wheel’s orientation.
Use angleDelta() instead.
sourcepub fn pos(&self) -> Point<'_>
pub fn pos(&self) -> Point<'_>
Returns the position of the mouse cursor relative to the widget that received the event.
If you move your widgets around in response to mouse events, use globalPos() instead of this function.
See also: [x()
]
[y()
]
[global_pos()
]
Returns the position of the mouse cursor relative to the widget that received the event.
If you move your widgets around in response to mouse events, use globalPosF() instead of this function.
See also: [global_pos_f()
]
sourcepub fn global_pos(&self) -> Point<'_>
pub fn global_pos(&self) -> Point<'_>
Returns the global position of the mouse pointer at the time of the event . This is important on asynchronous window systems such as X11; whenever you move your widgets around in response to mouse events, globalPos() can differ a lot from the current cursor position returned by QCursor::pos().
See also: [global_x()
]
[global_y()
]
Returns the global position of the mouse pointer at the time of the event . This is important on asynchronous window systems such as X11; whenever you move your widgets around in response to mouse events, globalPosF() can differ a lot from the current cursor position returned by QCursor::pos().
See also: [pos_f()
]
sourcepub fn x(&self) -> i32
pub fn x(&self) -> i32
Returns the x position of the mouse cursor, relative to the widget that received the event.
See also: [y()
]
[pos()
]
sourcepub fn y(&self) -> i32
pub fn y(&self) -> i32
Returns the y position of the mouse cursor, relative to the widget that received the event.
See also: [x()
]
[pos()
]
sourcepub fn global_x(&self) -> i32
pub fn global_x(&self) -> i32
Returns the global x position of the mouse cursor at the time of the event.
See also: [global_y()
]
[global_pos()
]
sourcepub fn global_y(&self) -> i32
pub fn global_y(&self) -> i32
Returns the global y position of the mouse cursor at the time of the event.
See also: [global_x()
]
[global_pos()
]
sourcepub fn pos_f(&self) -> Option<PointF<'_>>
pub fn pos_f(&self) -> Option<PointF<'_>>
Returns the position of the mouse cursor relative to the widget that received the event.
If you move your widgets around in response to mouse events, use globalPosF() instead of this function.
See also: [global_pos_f()
]
sourcepub fn global_pos_f(&self) -> Option<PointF<'_>>
pub fn global_pos_f(&self) -> Option<PointF<'_>>
Returns the global position of the mouse pointer at the time of the event . This is important on asynchronous window systems such as X11; whenever you move your widgets around in response to mouse events, globalPosF() can differ a lot from the current cursor position returned by QCursor::pos().
See also: [pos_f()
]
Returns the mouse state when the event occurred.
sourcepub fn phase(&self) -> ScrollPhase
pub fn phase(&self) -> ScrollPhase
Returns the scrolling phase of this wheel event.
Note: The Qt::ScrollBegin and Qt::ScrollEnd phases are currently supported only on MacOS .
sourcepub fn inverted(&self) -> bool
pub fn inverted(&self) -> bool
Returns whether the delta values delivered with the event are inverted.
Normally, a vertical wheel will produce a QWheelEvent with positive delta values if the top of the wheel is rotating away from the hand operating it. Similarly, a horizontal wheel movement will produce a QWheelEvent with positive delta values if the top of the wheel is moved to the left.
However, on some platforms this is configurable, so that the same operations described above will produce negative delta values (but with the same magnitude). With the inverted property a wheel event consumer can choose to always follow the direction of the wheel, regardless of the system settings, but only for specific widgets. (One such use case could be that the user is rotating the wheel in the same direction as a visual Tumbler rotates. Another usecase is to make a slider handle follow the direction of movement of fingers on a touchpad regardless of system configuration.)
Note: Many platforms provide no such information. On such platforms inverted always returns false.
sourcepub fn source(&self) -> MouseEventSource
pub fn source(&self) -> MouseEventSource
Returns information about the wheel event source.
The source can be used to distinguish between events that come from a mouse with a physical wheel and events that are generated by some other means, such as a flick gesture on a touchpad.
Note: Many platforms provide no such information. On such platforms Qt::MouseEventNotSynthesized is returned always.
See also: [t::mouse_event_source()
]
Trait Implementations
sourceimpl<'a> Clone for WheelEvent<'a>
impl<'a> Clone for WheelEvent<'a>
sourcefn clone(&self) -> WheelEvent<'a>
fn clone(&self) -> WheelEvent<'a>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more