module Iup::ButtonCallback

Standard callback method for when a mouse button is pressed or released.

Public Instance Methods

button_cb(callback) click to toggle source

Action generated when any mouse button is pressed or released. button_cb takes a callback which accepts 5 arguments (button, state, x, y, status)

button

the number of the button that changed, one of: BUTTON1 (left), BUTTON2 (middle), BUTTON3 (right)

state

1 for 'pressed', 0 for 'released'

x

x-coordinate

y

y-coordinate

status

status of the mouse buttons and some keyboard keys at the moment the event is generated.

# File lib/wrapped/common-attributes.rb, line 51
def button_cb callback
  unless callback.arity == 5
    raise ArgumentError, 'button_cb callback must take 5 arguments: (button, state, x, y, status)'
  end
  cb = Proc.new do |ih, b, p, x, y, status|
    callback.call b.chr, p, x, y, status
  end
  define_callback cb, 'BUTTON_CB', :iiiis_i
end