Changeset 2134 for trunk/lang/tcl/scripts/objects/boolean/boolean.rp
- Timestamp:
- Mar 14, 2011 10:58:06 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lang/tcl/scripts/objects/boolean/boolean.rp
r2080 r2134 1 1 object boolean -extends base { 2 2 palettes "Inputs" 3 3 4 help http://rappture.org/wiki/rp_xml_ele_boolean 5 4 6 attr default -title "Default Value" -type boolean -path default 5 7 6 check label { 7 if {[string length [string trim $attr(label)]] == 0} { 8 return [list warning "Should set a label that describes this value."] 8 storage { 9 private variable _val ;# boolean value 10 } 11 12 import xml {xmlobj path} { 13 import_string [$xmlobj get $path.current] 14 } 15 16 export xml {xmlobj path} { 17 set v [expr {($_val) ? "true" : "false"}] 18 $xmlobj put $path $v 19 } 20 21 import string {val} { 22 if {[string is boolean -strict $val]} { 23 set _val $val 24 } else { 25 error "don't recognize value" 9 26 } 10 27 } 11 check description { 12 set desc [string trim $attr(description)] 13 if {[string length $desc] == 0} { 14 return [list warning "Should include a description of what this value represents, typical settings, etc."] 15 } elseif {[string equal $desc $attr(label)]} { 16 return [list warning "Description should be different from the label and give additional information about the value."] 28 29 export string {var} { 30 upvar $var v 31 set v [expr {($_val) ? "true" : "false"}] 32 } 33 34 compare { 35 if {$_val && !$_val2} { 36 return 1 37 } elseif {!$_val && $_val} { 38 return -1 17 39 } 40 return 0 18 41 } 19 42 }
Note: See TracChangeset
for help on using the changeset viewer.