class Iup::Val

Val is a control allowing the user to select a value within a limited range.

Attributes

canfocus

Enables the control to gain focus. Values 'yes' / 'no'.

expand

Allows button to fill available space in indicated direction. Values 'no' / 'horizontal' / 'vertical' / 'yes'.

inverted

If set, places maximum value on opposite side: values 'yes' / 'no'.

max

maximum value, defaults to 1.

min

minimum value, defaults to 0.

orientation

'horizontal' / 'vertical'

pagestep

Proportion of increment for pageup / pagedown. Value between 0.0 and 1.0, default is 0.1.

position

read-only returns position in pixels within client window as “x,y”.

rastersize

Size of the control, in pixels, value as “widthxheight”.

screenposition

read-only returns position in pixels on screen as “x,y”.

step

Proportion of increment for up / down. Value between 0.0 and 1.0, default is 0.01.

Public Class Methods

new(orientation=nil, &block) click to toggle source

Creates an instance of the control.

orientation

'horizontal' / 'vertical'

block

optional block to set up control's attributes.

# File lib/wrapped/val.rb, line 29
def initialize orientation=nil, &block
  @handle = IupLib.IupVal orientation

  # run any provided block on instance, to set up further attributes
  self.instance_eval &block if block_given?
end

Public Instance Methods

button_press_cb(callback) click to toggle source

Calls callback when mouse button pressed to change the control value.

# File lib/wrapped/val.rb, line 54
def button_press_cb callback
  unless callback.arity.zero?
    raise ArgumentError, 'button_press_cb callback must take 0 arguments'
  end
  cb = Proc.new do |ih|
    callback.call
  end
  define_callback cb, 'BUTTON_PRESS_CB', :plain
end
button_release_cb(callback) click to toggle source

Calls callback when mouse button released.

# File lib/wrapped/val.rb, line 65
def button_release_cb callback
  unless callback.arity.zero?
    raise ArgumentError, 'button_release_cb callback must take 0 arguments'
  end
  cb = Proc.new do |ih, a|
    callback.call
  end
  define_callback cb, 'BUTTON_RELEASE_CB', :plain
end
mousemove_cb(callback) click to toggle source

Calls callback when mouse is used to move control.

# File lib/wrapped/val.rb, line 76
def mousemove_cb callback
  unless callback.arity.zero?
    raise ArgumentError, 'mousemove_cb callback must take 0 arguments'
  end
  cb = Proc.new do |ih, a|
    callback.call
  end
  define_callback cb, 'MOUSEMOVE_CB', :plain
end
valuechanged_cb(callback) click to toggle source

Calls callback after the value was interactively changed by the user.

# File lib/wrapped/val.rb, line 87
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