CrystGLFW::Event::WindowMouseButton

A CrystGLFW::Event::WindowMouseButton is generated when a mouse button is pressed/released while a Window has input focus. It is yielded to the block defined by on_mouse_button.

window = Window.new

window.on_mouse_button do |event|
  mouse_button = event.mouse_button
  if event.action.press? && mouse_button.left?
    puts "the left mouse button was clicked"
  end  
end

window

You can retrieve the event's associated Window using the window method:

event.window # => CrystGLFW::Window

mouse_button

You can retrieve the MouseButton that was pressed/released using the mouse_button method:

event.mouse_button # => CrystGLFW::MouseButton

action

You can retrieve the Action that was performed using the action method:

if event.action.press?
  puts "mouse button was pressed"
elsif event.action.release?
  puts "mouse button was released"
else
  puts "impossible!"
end

Modifiers

You can also use any of the methods from the Modifiers module on a CrystGLFW::Event::WindowMouseButton.

results matching ""

    No results matching ""