class Iup::Toggle
A control that can have two or three states, and displays either some text or an image.
Example
(1) with text label
Iup::Toggle.new('click to change')
(2) with a standard image, reporting changes to value
Iup::Toggle.new do |t| t.image = "IUP_MessageHelp" t.valuechanged_cb = ->{ puts "button 1 state #{toggle1.value}" } end
Attributes
Sets the horizontal and vertical alignment. The value is a string âhorizontal:verticalâ, with horizontal options ALEFT, ACENTER, ARIGHT and vertical options ATOP, ACENTER, ABOTTOM. Partial values also accepted, e.g. âARIGHTâ, â:ATOPâ.
Enables the control to gain focus. Values âyesâ / ânoâ.
Allows control to fill available space in indicated direction. Values ânoâ / âhorizontalâ / âverticalâ / âyesâ.
If set, hides the controlâs border until mouse enters the button area. Values âyesâ / ânoâ.
Margin in x and y directions, value as âmxnâ.
Returns position in pixels within client window as âx,yâ.
Returns âyesâ / ânoâ, if toggle is within a radio control.
Size of the control, in pixels, value as âwidthxheightâ.
returns position in pixels on screen as âx,yâ.
ânoâ / âyesâ, 3-state only for text labels, and not in a radio control.
Tooltip string.
text to display.
Toggleâs state, value one of âonâ / âoffâ / âtoggleâ / ânotdefâ (for 3-state toggles).
Public Class Methods
Source
# File lib/wrapped/toggle.rb, line 25 def initialize(title=nil) @handle = IupLib.IupToggle(title, '') # run any provided block on instance, to set up further attributes yield self if block_given? end
Creates a new instance. If a block is given, the new instance is yielded to it.
-
title- optional text to display
Callbacks
Attributes
Callback called when the toggleâs state (on/off) was changed. Callback must respond to call and takes a 1-argument callback: (state_change)
-
state_change- state changed to âonâ or âoffâ gives value 1 or 0
Callback called after the value was interactively changed by the user. Callback must respond to call and take no arguments.