class Iup::Dial
Public Class Methods
new(orientation = 'horizontal', &block)
click to toggle source
# File lib/wrapped/dial.rb, line 5 def initialize orientation = 'horizontal', &block open_controls @handle = ControlsLib.IupDial orientation # run any provided block on instance, to set up further attributes self.instance_eval &block if block_given? end
Public Instance Methods
mousemove_cb(callback)
click to toggle source
Called each time the user moves the dial with the mouse button pressed. The angle the dial rotated since it was initialized is passed as a parameter. Callback is a 1-argument function: (angle)
# File lib/wrapped/dial.rb, line 65 def mousemove_cb callback unless callback.arity == 1 raise ArgumentError, 'mousemove_cb callback must take 1 argument: (angle)' end cb = Proc.new do |ih, angle| callback.call angle end define_callback cb, 'MOUSEMOVE_CB', :d_i end
value(val=nil)
click to toggle source
# File lib/wrapped/dial.rb, line 23 def value val=nil if val.nil? result = IupLib.IupGetAttribute(@handle, 'VALUE').first result.to_f else IupLib.IupSetAttribute @handle, 'VALUE', val.to_s end end
valuechanged_cb(callback)
click to toggle source
Called after the value was interactively changed by the user. Called when the selection is changed or when the text is edited.
# File lib/wrapped/dial.rb, line 77 def valuechanged_cb callback unless callback.arity.zero? raise ArgumentError, 'valuechanged_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'VALUECHANGED_CB', :plain end