Class: Iup::Val
Overview
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.
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#button_press_cb(callback) ⇒ Object
Calls callback when mouse button pressed to change the control value.
-
#button_release_cb(callback) ⇒ Object
Calls callback when mouse button released.
-
#initialize(orientation = nil, &block) ⇒ Val
constructor
Creates an instance of the control.
-
#mousemove_cb(callback) ⇒ Object
Calls callback when mouse is used to move control.
-
#valuechanged_cb(callback) ⇒ Object
Calls callback after the value was interactively changed by the user.
Methods inherited from Widget
#assign_handle, #enterwindow_cb, #getfocus_cb, #help_cb, #k_any, #killfocus_cb, #leavewindow_cb, #map_cb, #open_controls, #unmap_cb
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly
Methods included from CallbackSetter
Constructor Details
#initialize(orientation = nil, &block) ⇒ Val
Creates an instance of the control.
- orientation
-
‘horizontal’ / ‘vertical’
- block
-
optional block to set up control’s attributes.
29 30 31 32 33 34 |
# 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 |
Instance Method Details
#button_press_cb(callback) ⇒ Object
Calls callback when mouse button pressed to change the control value.
54 55 56 57 58 59 60 61 62 |
# File 'lib/wrapped/val.rb', line 54 def 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) ⇒ Object
Calls callback when mouse button released.
65 66 67 68 69 70 71 72 73 |
# File 'lib/wrapped/val.rb', line 65 def 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) ⇒ Object
Calls callback when mouse is used to move control.
76 77 78 79 80 81 82 83 84 |
# 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) ⇒ Object
Calls callback after the value was interactively changed by the user.
87 88 89 90 91 92 93 94 95 |
# 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 |