Handling Input

 

MouseEvent | KeyEvent | Key | AccelerationEvent | SystemEvent | Input

  

MouseEvent
compound
  • DESCRIPTION
    • Contains information about a specific mouse event. Override on(MouseEvent) in your Screen subclass to handle mouse events.
    • Members (read-only):
        type
          One of: 
            MouseEvent.movement
            MouseEvent.relative_movement,
            MouseEvent.button_press
            MouseEvent.button_release,
            MouseEvent.wheel_up
            MouseEvent.wheel_down, 
            MouseEvent.present
            MouseEvent.absent
      
        mouse_id
          Which mouse is being used.  Normally this will be 1.  For
          iPhone, each different simultaneous touch is sent as a
          different mouse_id that will remain the same throughout the
          duration of the touch.
      
        position
          The mouse position at the time of the mouse event.
      
        button
          The mouse button that was pressed for appropriate events.
      
      
  • PROPERTIES
    • type : Int32
    • mouse_id : Int32
    • position : Vector2
    • button : Int32
  • METHODS
    • init(Int32 type,Int32 mouse_id,Vector2 position,Int32 button).MouseEvent
    • init(MouseEvent MouseEvent).MouseEvent

 

KeyEvent
compound
  • DESCRIPTION
    • Contains information about a specific key event. Override on(KeyEvent) in your Screen subclass to handle key events.
    • Members (read-only):
        type
          One of: 
            KeyEvent.press
            KeyEvent.repeat
            KeyEvent.release
      
        keycode
          The raw keycode of the key pressed - Key.keycode_a,
          Key.keycode_0, etc.  Corresponds to SDL keycode values.
      
        unicode
          The unicode value of the key pressed - 'A', '0', etc.
      
        modifiers
          Flags indicating what key modifiers were pressed at the time
          of the key event.  Use the following methods to check
          (event is the KeyEvent; the methods are actualy defined
          in class KeyEventManager).
      
            event.shift_pressed
            event.ctrl_pressed
            event.alt_pressed
            event.caps_locked
      
  • PROPERTIES
    • type : Int32
    • keycode : Int32
    • unicode : Char
    • modifiers : Int32
  • METHODS
    • init(Int32 type,Int32 keycode,Char unicode,Int32 modifiers).KeyEvent
    • init(KeyEvent KeyEvent).KeyEvent

 

Key
singleton class : Object
  • DESCRIPTION
    • A collection of key constants. Compare these with the keycode values in your Key events or use them as indices into the Input.key_state[] table.
  • PROPERTIES
    • modifier_shift : Int32
    • modifier_ctrl : Int32
    • modifier_alt : Int32
    • modifier_caps_lock : Int32
    • keycode_backspace : Int32
    • keycode_tab : Int32
    • keycode_enter : Int32
    • keycode_pause : Int32
    • keycode_escape : Int32
    • keycode_space : Int32
    • keycode_exclaim : Int32
    • keycode_quote : Int32
    • keycode_hash : Int32
    • keycode_dollar : Int32
    • keycode_ampersand : Int32
    • keycode_apostrophe : Int32
    • keycode_left_paren : Int32
    • keycode_right_paren : Int32
    • keycode_asterisk : Int32
    • keycode_plus : Int32
    • keycode_comma : Int32
    • keycode_minus : Int32
    • keycode_period : Int32
    • keycode_slash : Int32
    • keycode_0 : Int32
    • keycode_1 : Int32
    • keycode_2 : Int32
    • keycode_3 : Int32
    • keycode_4 : Int32
    • keycode_5 : Int32
    • keycode_6 : Int32
    • keycode_7 : Int32
    • keycode_8 : Int32
    • keycode_9 : Int32
    • keycode_colon : Int32
    • keycode_semicolon : Int32
    • keycode_less : Int32
    • keycode_equals : Int32
    • keycode_greater : Int32
    • keycode_question : Int32
    • keycode_at : Int32
    • keycode_left_bracket : Int32
    • keycode_backslash : Int32
    • keycode_right_bracket : Int32
    • keycode_circumflex : Int32
    • keycode_underline : Int32
    • keycode_grave : Int32
    • keycode_a : Int32
    • keycode_b : Int32
    • keycode_c : Int32
    • keycode_d : Int32
    • keycode_e : Int32
    • keycode_f : Int32
    • keycode_g : Int32
    • keycode_h : Int32
    • keycode_i : Int32
    • keycode_j : Int32
    • keycode_k : Int32
    • keycode_l : Int32
    • keycode_m : Int32
    • keycode_n : Int32
    • keycode_o : Int32
    • keycode_p : Int32
    • keycode_q : Int32
    • keycode_r : Int32
    • keycode_s : Int32
    • keycode_t : Int32
    • keycode_u : Int32
    • keycode_v : Int32
    • keycode_w : Int32
    • keycode_x : Int32
    • keycode_y : Int32
    • keycode_z : Int32
    • keycode_delete : Int32
    • keycode_numpad_0 : Int32
    • keycode_numpad_1 : Int32
    • keycode_numpad_2 : Int32
    • keycode_numpad_3 : Int32
    • keycode_numpad_4 : Int32
    • keycode_numpad_5 : Int32
    • keycode_numpad_6 : Int32
    • keycode_numpad_7 : Int32
    • keycode_numpad_8 : Int32
    • keycode_numpad_9 : Int32
    • keycode_numpad_period : Int32
    • keycode_numpad_slash : Int32
    • keycode_numpad_star : Int32
    • keycode_numpad_minus : Int32
    • keycode_numpad_plus : Int32
    • keycode_numpad_enter : Int32
    • keycode_numpad_equals : Int32
    • keycode_up_arrow : Int32
    • keycode_down_arrow : Int32
    • keycode_right_arrow : Int32
    • keycode_left_arrow : Int32
    • keycode_insert : Int32
    • keycode_home : Int32
    • keycode_end : Int32
    • keycode_page_up : Int32
    • keycode_page_down : Int32
    • keycode_f1 : Int32
    • keycode_f2 : Int32
    • keycode_f3 : Int32
    • keycode_f4 : Int32
    • keycode_f5 : Int32
    • keycode_f6 : Int32
    • keycode_f7 : Int32
    • keycode_f8 : Int32
    • keycode_f9 : Int32
    • keycode_f10 : Int32
    • keycode_f11 : Int32
    • keycode_f12 : Int32
    • keycode_f13 : Int32
    • keycode_f14 : Int32
    • keycode_f15 : Int32
    • keycode_num_lock : Int32
    • keycode_caps_lock : Int32
    • keycode_scroll : Int32
    • keycode_right_shift : Int32
    • keycode_left_shift : Int32
    • keycode_right_ctrl : Int32
    • keycode_left_ctrl : Int32
    • keycode_right_alt : Int32
    • keycode_left_alt : Int32
    • keycode_right_win : Int32
    • keycode_right_meta : Int32
    • keycode_right_command : Int32
    • keycode_left_win : Int32
    • keycode_left_meta : Int32
    • keycode_left_command : Int32
    • keycode_sys_request : Int32
    • keycode_first_printable : Int32
    • keycode_last_printable : Int32
    • keycode_to_unicode_lc : Char[]
    • keycode_to_unicode_uc : Char[]
    • unicode_to_keycode : Char[]
  • METHODS
    • init()
    • init_object()
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods

 

AccelerationEvent
compound
  • DESCRIPTION
    • Contains information about a specific acceleration event. Override on(AccelerationEvent) in your Screen subclass to handle accleration events.
    • Members (read-only):
        controller_id
          Which controller is being used.  This will be 1 on the iPhone;
          it can be 1..4 on the Wii.
      
        x, y, z
          The acceleration on the x, y, and z axes.
      
    • Methods (defined in class AccelerationEventManager):

          orientation().RollPitchYaw
            Returns a RollPitchYaw compound (containing roll,pitch,yaw:Radians)
            with the orientation of the device assuming that gravity is 
            the primary force acting on the device (in other words this
            doesn't work if it's being shaken violently).
  • PROPERTIES
    • controller_id : Int32
    • x : Real64
    • y : Real64
    • z : Real64
  • METHODS
    • init(Int32 controller_id,Real64 x,Real64 y,Real64 z).AccelerationEvent
    • init(AccelerationEvent AccelerationEvent).AccelerationEvent

  

SystemEvent
compound
  • DESCRIPTION
    • Contains information about a specific system event. Override on(SystemEvent) in your Screen subclass to handle System events.
    • Members (read-only):
        type
          One of:
            SystemEvent.garbage_collected
              Indicates that a garbage collection has just finished.
      
            SystemEvent.resources_loaded
              Indicates that all resources have finished loading as a
              a consequence of an earlier call to ResourceManager.load().
      
  • PROPERTIES
    • type : Int32
  • METHODS
    • init(Int32 type).SystemEvent
    • init(SystemEvent SystemEvent).SystemEvent

 

Input
singleton class : Object, InputDispatcher
  • DESCRIPTION
    • Manages application input. Depending on your application you may wish to handle input event messages in your Screen subclass (on(MouseEvent) etc.) or use this class to poll the current input state.
  • PROPERTIES
    • input_listeners : InputListener[]
      • List of key listeners receiving events from this dispatcher.
    • first_repeat_delay_in_ticks : Int32
      • Internal use.
    • next_repeat_delay_in_ticks : Int32
    • key_modifiers : Int32
      • The set of flags representing which SHIFT, ALT, and CTRL key modifiers are currently pressed. Most applications will want to call one of these methods instead:
      •   shift_pressed()
          ctrl_pressed()
          alt_pressed()
          caps_locked()
        
    • key_state : Logical[]
      • "true" if the given raw keycode (e.g. Key.keycode_a) is currently pressed, "false" if not.
    • last_key_pressed : Int32
      • Internal use - used for key repeating.
    • key_repeat_delay_in_ticks : Int32
      • Internal use - a countdown until a pressed key repeats.
    • mouse_present : Logical
      • "true" if this application has the mouse focus.
    • mouse_button_state : Logical[]
      • mouse_button_state[i] (where i is 1 to 10) is "true" if that mouse button is currently pressed.
    • joystick_connected : Logical[]
      • True if a given joystick 1..4 is detected and able to provide input. Currently disabled on all platforms.
  • METHODS
    • init()
    • shift_pressed().Logical
      • Returns "true" if either of the shift keys is currently pressed.
    • shift_pressed(Logical setting)
      • Internal use - shift_pressed property-set.
    • caps_locked().Logical
      • Returns "true" if CAPS LOCK is on.
    • caps_locked(Logical setting)
      • Internal use - caps_locked property-set.
    • ctrl_pressed().Logical
      • Returns "true" if either of the control keys is currently pressed.
    • ctrl_pressed(Logical setting)
      • Internal use - ctrl_pressed property-set.
    • alt_pressed().Logical
      • Returns "true" if either of the alt keys is currently pressed.
    • alt_pressed(Logical setting)
      • Internal use - alt_pressed property-set.
    • update()
    • keycode_to_Char(Int32 keycode).Char
      • Converts the given keycode into its Unicode equivalent, taking the current shift keys into consideration. test special cases in the midst of the printable char range
    • handle_event(Int32 type,Int32 id,Int32 i,Real64 x,Real64 y)
      • Internal use - called by the native layer to relay input events.
    • init_object()
    • dispatch(KeyEvent event)
      • Sends the given key event to all registered listeners.
    • dispatch(MouseEvent event)
      • Sends the given mouse event to all registered listeners.
    • dispatch(JoystickEvent event)
      • Sends the given joystick event to all registered listeners.
    • dispatch(AccelerationEvent event)
      • Sends the given acceleration event to all registered listeners.
    • dispatch(SystemEvent event)
      • Sends the given system event to all registered listeners.
    • input_listeners().InputListener[]
    • input_listeners(InputListener[] input_listeners.1233)
    • active_input_listeners().InputListener[]
    • active_input_listeners(InputListener[] active_input_listeners.1234)
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods