S or /

SourceClass PointerState

from egui import PointerState
class PointerState:

Mouse or touch state.

To access the methods of PointerState you can use the egui.Context.input function

Methods§

Sourcedef any_click(self, /) -> bool§

Were there any type of click this frame?

Sourcedef any_down(self, /) -> bool§

Is any pointer button currently down?

Buttons released this frame are NOT considered down.

Sourcedef any_pressed(self, /) -> bool§

Was any pointer button pressed (!down -> down) this frame?

This can sometimes return True even if any_down() == False because a press can be shorted than one frame.

Sourcedef any_released(self, /) -> bool§

Was any pointer button released (down -> !down) this frame?

Sourcedef button_clicked(self, /, button: PointerButton) -> bool§

Was the given pointer button given clicked this frame?

A click is registered when the mouse or touch is released within a certain amount of time and distance from when and where it was pressed.

Returns true on double- and triple- clicks too.

Sourcedef button_double_clicked(self, /, button: PointerButton) -> bool§

Was the button given double clicked this frame?

Sourcedef button_down(self, /, button: PointerButton) -> bool§

Is this button currently down?

Buttons released this frame are NOT considered down.

Sourcedef button_pressed(self, /, button: PointerButton) -> bool§

Was the button given pressed this frame?

Sourcedef button_released(self, /, button: PointerButton) -> bool§

Was the button given released this frame?

Sourcedef button_triple_clicked(self, /, button: PointerButton) -> bool§

Was the button given triple clicked this frame?

Sourcedef could_any_button_be_click(self, /) -> bool§

If the pointer button is down, will it register as a click when released?

See also egui.PointerState.is_decidedly_dragging.

@staticmethod def default() -> PointerState§
Sourcedef delta(self, /) -> Vec2§

How much the pointer moved compared to last frame, in points.

Sourcedef direction(self, /) -> Vec2§

Current direction of the pointer.

This is less sensitive to bad framerate than egui.PointerState.velocity.

Sourcedef has_pointer(self, /) -> bool§

Do we have a pointer?

False if the mouse is not over the egui area, or if no touches are down on touch screens.

Sourcedef hover_pos(self, /) -> Pos2 |None§

If it is a good idea to show a tooltip, where is pointer?

Sourcedef interact_pos(self, /) -> Pos2 |None§

If you detect a click or drag and wants to know where it happened, use this.

Latest position of the mouse, but ignoring any Event.PointerGone if there were interactions this frame. When tapping a touch screen, this will be the location of the touch.

Sourcedef is_decidedly_dragging(self, /) -> bool§

Just because the mouse is down doesn't mean we are dragging. We could be at the start of a click. But if the mouse is down long enough, or has moved far enough, then we consider it a drag.

This function can return true on the same frame the drag is released, but NOT on the first frame it was started.

See also egui.PointerState.could_any_button_be_click.

Sourcedef is_moving(self, /) -> bool§

Is the pointer currently moving? This is smoothed so a few frames of stillness is required before this returns False.

Sourcedef is_moving_towards_rect(self, /, rect: Rect) -> bool§

Is the mouse moving in the direction of the given rect?

Sourcedef is_still(self, /) -> bool§

Is the pointer currently still? This is smoothed so a few frames of stillness is required before this returns True.

Sourcedef latest_pos(self, /) -> Pos2 |None§

Latest reported pointer position. When tapping a touch screen, this will be None.

Sourcedef middle_down(self, /) -> bool§

Is the middle button currently down?

Buttons released this frame are NOT considered down.

Sourcedef motion(self, /) -> Vec2 |None§

How much the mouse moved since the last frame, in unspecified units. Represents the actual movement of the mouse, without acceleration or clamped by screen edges. May be unavailable on some integrations.

Sourcedef press_origin(self, /) -> Pos2 |None§

Where did the current click/drag originate? None if no mouse button is down.

Sourcedef press_start_time(self, /) -> float |None§

When did the current click/drag originate? None if no mouse button is down.

Sourcedef primary_clicked(self, /) -> bool§

Was the primary button clicked this frame?

A click is registered when the mouse or touch is released within a certain amount of time and distance from when and where it was pressed.

Sourcedef primary_down(self, /) -> bool§

Is the primary button currently down?

Buttons released this frame are NOT considered down.

Sourcedef primary_pressed(self, /) -> bool§

Was the primary button pressed this frame?

Sourcedef primary_released(self, /) -> bool§

Was the primary button released this frame?

Sourcedef secondary_clicked(self, /) -> bool§

Was the secondary button clicked this frame?

A click is registered when the mouse or touch is released within a certain amount of time and distance from when and where it was pressed.

Sourcedef secondary_down(self, /) -> bool§

Is the secondary button currently down?

Buttons released this frame are NOT considered down.

Sourcedef secondary_pressed(self, /) -> bool§

Was the secondary button pressed this frame?

Sourcedef secondary_released(self, /) -> bool§

Was the secondary button released this frame?

Sourcedef time_since_last_click(self, /) -> float§

How long has it been (in seconds) since the pointer was clicked?

Sourcedef time_since_last_movement(self, /) -> float§

How long has it been (in seconds) since the pointer was last moved?

Sourcedef total_drag_delta(self, /) -> Vec2 |None§

How far has the pointer moved since the start of the drag (if any)?

Sourcedef velocity(self, /) -> Vec2§

Current velocity of pointer.

This is smoothed over a few frames, but can be ZERO when frame-rate is bad.