Changeset 1929 for trunk/gui/scripts/dropdown.tcl
- Timestamp:
- Oct 22, 2010, 4:06:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/dropdown.tcl
r1594 r1929 37 37 38 38 bind RapptureDropdown <ButtonPress> \ 39 39 {if {[Rappture::Dropdown::outside %W %X %Y]} {%W unpost}} 40 40 } 41 41 … … 75 75 76 76 if {[string length $itk_option(-postcommand)] > 0} { 77 78 79 80 77 set cmd [list uplevel #0 $itk_option(-postcommand)] 78 if {[catch $cmd result]} { 79 bgerror $result 80 } 81 81 } 82 82 … … 87 87 88 88 if {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} { 89 90 89 set xpos $x 90 set ypos $y 91 91 } elseif {[winfo exists $where]} { 92 93 94 95 96 97 98 99 100 92 set x0 [winfo rootx $where] 93 switch -- $args { 94 left { set xpos $x0 } 95 right { set xpos [expr {$x0 + [winfo width $where] - $sw}] } 96 default { 97 error "bad option \"$args\": should be left, right" 98 } 99 } 100 set ypos [expr {[winfo rooty $where]+[winfo height $where]}] 101 101 } else { 102 102 error "bad position \"$where\": should be widget name or @x,y" 103 103 } 104 104 105 105 # make sure the dropdown doesn't go off screen 106 106 if {$xpos > 0} { 107 108 109 110 111 112 107 # left-justified positions 108 if {$xpos + $w > $sw} { 109 set xpos [expr {$sw-$w}] 110 if {$xpos < 0} { set xpos 0 } 111 } 112 set xpos "+$xpos" 113 113 } else { 114 115 116 117 118 114 # right-justified positions 115 if {$xpos - $w < -$sw} { 116 set xpos [expr {-$sw+$w}] 117 if {$xpos > 0} { set xpos -1 } 118 } 119 119 } 120 120 if {$ypos + $h > $sh} { 121 122 121 set ypos [expr {$sh-$h}] 122 if {$ypos < 0} { set ypos 0 } 123 123 } 124 124 … … 133 133 update 134 134 while {[catch {grab set -global $itk_component(hull)}]} { 135 135 after 100 136 136 } 137 137 } … … 147 147 148 148 if {[string length $itk_option(-unpostcommand)] > 0} { 149 150 151 152 149 set cmd [list uplevel #0 $itk_option(-unpostcommand)] 150 if {[catch $cmd result]} { 151 bgerror $result 152 } 153 153 } 154 154 } … … 172 172 itcl::body Rappture::Dropdown::outside {widget x y} { 173 173 return [expr {$x < [winfo rootx $widget] 174 175 176 174 || $x > [winfo rootx $widget]+[winfo width $widget] 175 || $y < [winfo rooty $widget] 176 || $y > [winfo rooty $widget]+[winfo height $widget]}] 177 177 } 178 178
Note: See TracChangeset
for help on using the changeset viewer.