Module: Iup::ButtonCallback

Included in:
Button, Canvas, Dial, Label, List, Scintilla, ScrollBox, Text, Tree
Defined in:
lib/wrapped/common-attributes.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#button_cb(callback) ⇒ Object

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.

– TODO: include status test methods iup_iscontrol etc



51
52
53
54
55
56
57
58
59
# 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