Help - Search - Members - Calendar
Full Version: Calling methods on arrow keys
RPG RPG Revolution Forums > Scripting > Script Development and Support > Script Requests
Tsukihime
I want another window to refresh itself to the currently selected item in a selectable window whenever I hit any of the keys that move the cursor (up, down, left, right, pg up, pg down). How can I tell that window to refresh when I hit one of those keys?
Night_Runner
CODE
if Input.repeat?(Input.dir4) or Input.trigger?(:L) or Input.trigger?(:R)
window.refresh
end


I've used Input.repeat?, which is what the system uses for scrolling though selectable windows, but you can also use Input.trigger? which only activated when you start pressing the buttons.

But otherwise the code that the windows use to check if selected item has moved is
CODE
  #--------------------------------------------------------------------------
  # * Cursor Movement Processing
  #--------------------------------------------------------------------------
  def process_cursor_move
    return unless cursor_movable?
    last_index = @index
    cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
    cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
    cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
    cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
    cursor_pagedown   if !handle?(:pagedown) && Input.trigger?(:R)
    cursor_pageup     if !handle?(:pageup)   && Input.trigger?(:L)
    Sound.play_cursor if @index != last_index
  end
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.