Skip to content

Class PointerButtonEvent ​

A button press or release, from a device or from pointer:button. pointer_button handlers get it before the app under the pointer and can stop it. pointer_button_forwarded handlers get it after the app.

A right click on a window with Super held, kept from the app:

lua
wm.input:on("pointer_button", function(event)
	if event.button ~= Button.Right or not event.modifiers.super then return end
	if not event.pointer:window_under() then return end
	event:prevent_default()
end)

Properties ​

event.pointer: Pointerpointer read only ​

The pointer whose button it is. event.pointer:position() is where the click happened.

event.button: MouseButtonbutton read only ​

Which button. Compare it with a Button.* value: event.button == Button.Left.

  • Comparing with a string or number using == is always false. Use tostring(event.button) == "Back" to match by name.

event.state: "Pressed" | "Released"state read only ​

Capitalised, unlike the state pointer:button takes.

event.modifiers: Modifiersmodifiers read only ​

The modifiers on the keyboard of the pointer's seat.

  • All false when the seat has no keyboard.

Methods ​

event:prevent_default() -> nilprevent_default ​

Keeps the button from the app. pointer_button_forwarded doesn't fire for it. Later pointer_button handlers still run.

  • pointer:buttons() counts the button either way.
  • Prevent the release as well as the press, or the app gets a release it never saw pressed.
  • Does nothing in a pointer_button_forwarded handler.