abstract class Eagle::Event

Overview

Base class for input and window events, delivered to App#input and Node#input.

Use events when you care that something happened: a key went down, a button was clicked, the window resized. For "is this key held right now?", ask Input instead.

Nodes receive events deepest-first, in reverse order of addition, so the thing drawn on top gets the first chance. Set handled = true to stop the event from reaching anything else.

class Menu < Node2D
  def input(event : Event) : Nil
    case event
    when KeyEvent
      if event.pressed? && event.key.escape?
        visible = !visible?
        event.handled = true
      end
    when MouseButtonEvent
      puts "click at #{event.position}" if event.pressed?
    end
  end
end

Direct Known Subclasses

Defined in:

eagle/core/events.cr

Instance Method Summary

Instance Method Detail

def handled=(handled : Bool) #

Set to true in a handler to stop the event from reaching later nodes.


def handled? : Bool #

Set to true in a handler to stop the event from reaching later nodes.