Struct gdk4::ButtonEvent

source ·
#[repr(transparent)]
pub struct ButtonEvent { /* private fields */ }
Expand description

An event related to a button on a pointer device.

Implementations§

source§

impl ButtonEvent

source

pub fn as_ptr(&self) -> *mut GdkButtonEvent

Return the inner pointer to the underlying C value.

source

pub unsafe fn from_glib_ptr_borrow<'a>( ptr: *const *const GdkButtonEvent ) -> &'a Self

Borrows the underlying C value.

source§

impl ButtonEvent

source

pub fn button(&self) -> u32

Extract the button number from a button event.

Returns

the button of @self

source§

impl ButtonEvent

source

pub fn upcast(self) -> Event

source

pub fn upcast_ref(&self) -> &Event

Methods from Deref<Target = Event>§

source

pub fn as_ptr(&self) -> *mut GdkEvent

Return the inner pointer to the underlying C value.

source

pub const NONE: Option<&'static Event> = None

source

pub fn axes(&self) -> Option<Vec<f64>>

Extracts all axis values from an event.

To find out which axes are used, use DeviceTool::axes() on the device tool returned by device_tool().

Returns

true on success, otherwise false

axes

the array of values for all axes

source

pub fn axis(&self, axis_use: AxisUse) -> Option<f64>

Extract the axis value for a particular axis use from an event structure.

To find out which axes are used, use DeviceTool::axes() on the device tool returned by device_tool().

axis_use

the axis use to look for

Returns

true if the specified axis was found, otherwise false

value

location to store the value found

source

pub fn device(&self) -> Option<Device>

Returns the device of an event.

Returns

a Device

source

pub fn device_tool(&self) -> Option<DeviceTool>

Returns a DeviceTool representing the tool that caused the event.

If the was not generated by a device that supports different tools (such as a tablet), this function will return None.

Note: the DeviceTool will be constant during the application lifetime, if settings must be stored persistently across runs, see DeviceTool::serial().

Returns

The current device tool

source

pub fn display(&self) -> Option<Display>

Retrieves the display associated to the @self.

Returns

a Display

source

pub fn event_sequence(&self) -> EventSequence

Returns the event sequence to which the event belongs.

Related touch events are connected in a sequence. Other events typically don’t have event sequence information.

Returns

the event sequence that the event belongs to

source

pub fn event_type(&self) -> EventType

Retrieves the type of the event.

Returns

a EventType

source

pub fn history(&self) -> Vec<TimeCoord>

Retrieves the history of the device that @self is for, as a list of time and coordinates.

The history includes positions that are not delivered as separate events to the application because they occurred in the same frame as @self.

Note that only motion and scroll events record history, and motion events do it only if one of the mouse buttons is down, or the device has a tool.

Returns

an array of time and coordinates

source

pub fn modifier_state(&self) -> ModifierType

Returns the modifier state field of an event.

Returns

the modifier state of @self

source

pub fn is_pointer_emulated(&self) -> bool

Returns whether this event is an ‘emulated’ pointer event.

Emulated pointer events typically originate from a touch events.

Returns

true if this event is emulated

source

pub fn position(&self) -> Option<(f64, f64)>

Extract the event surface relative x/y coordinates from an event.

Returns
x

location to put event surface x coordinate

y

location to put event surface y coordinate

source

pub fn seat(&self) -> Option<Seat>

Returns the seat that originated the event.

Returns

a Seat.

source

pub fn surface(&self) -> Option<Surface>

Extracts the surface associated with an event.

Returns

The Surface associated with the event

source

pub fn time(&self) -> u32

Returns the timestamp of @self.

Not all events have timestamps. In that case, this function returns GDK_CURRENT_TIME.

Returns

timestamp field from @self

source

pub fn triggers_context_menu(&self) -> bool

Returns whether a Event should trigger a context menu, according to platform conventions.

The right mouse button typically triggers context menus.

This function should always be used instead of simply checking for event->button == GDK_BUTTON_SECONDARY.

Returns

true if the event should trigger a context menu.

source

pub fn is<T: EventKind>(&self) -> bool

source

pub fn type_(&self) -> Type

source

pub fn downcast_ref<T: EventKind>(&self) -> Option<&T>

source

pub fn angle(&self, event: impl AsRef<Event>) -> Option<f64>

Returns the relative angle from @event1 to @event2.

The relative angle is the angle between the X axis and the line through both events’ positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

This assumes that both events have X/Y information. If not, this function returns false.

event1

first Event

event2

second Event

Returns

true if the angle could be calculated.

angle

return location for the relative angle between both events

source

pub fn center(&self, event: impl AsRef<Event>) -> Option<(f64, f64)>

Returns the point halfway between the events’ positions.

This assumes that both events have X/Y information. If not, this function returns false.

event1

first Event

event2

second Event

Returns

true if the center could be calculated.

x

return location for the X coordinate of the center

y

return location for the Y coordinate of the center

source

pub fn distance(&self, event: impl AsRef<Event>) -> Option<f64>

Returns the distance between the event locations.

This assumes that both events have X/Y information. If not, this function returns false.

event1

first Event

event2

second Event

Returns

true if the distance could be calculated.

distance

return location for the distance

Trait Implementations§

source§

impl AsRef<Event> for ButtonEvent

source§

fn as_ref(&self) -> &Event

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for ButtonEvent

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ButtonEvent

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for ButtonEvent

§

type Target = Event

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Display for ButtonEvent

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl EventKind for ButtonEvent

source§

fn event_types() -> &'static [EventType]

source§

impl StaticType for ButtonEvent

source§

fn static_type() -> Type

Returns the type identifier of Self.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticTypeExt for Twhere T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> TransparentType for Twhere T: TransparentPtrType,

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.