Bwidget Source Code
Check-in [a758127e75]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:* combobox.tcl (ComboBox::getvalue et al) fixed bug: getvalue returned first apearence of current data instead of clicked index, which may not be the same if values is not unique. Additional variable _index(path) added to hold click index [Bug 1610965] reported by Martin Lemburg
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a758127e75f0e7e9bc61fa9dcec07ec5fdd4e35e
User & Date: oehhar 2009-06-25 16:48:52.000
Context
2009-06-26
14:46
* listbox.tcl (ListBox::create et al) new feature: listbox option -listbox now read/write [Bug 1501874] reported by Stephen Huntley

* dynhelp.tcl (DynamicHelp::_show_help) fixed issue (as far as possible): Dynamic help baloon was on the main screen, if it touched the border on a windows multi screen configuration. The fix assumes, that all screens have same dimensions and no gaps in- between. This is necessary, because multi-screen configuration paramters may not be interrogated by tk (despite of coordinates out of the screen) [Bug 1499135] reported by Gregor check-in: 8860bd1e23 user: oehhar tags: trunk

2009-06-25
16:48
* combobox.tcl (ComboBox::getvalue et al) fixed bug: getvalue returned first apearence of current data instead of clicked index, which may not be the same if values is not unique. Additional variable _index(path) added to hold click index [Bug 1610965] reported by Martin Lemburg check-in: a758127e75 user: oehhar tags: trunk
2009-06-24
12:14
* buttonbox.tcl (ButtonBox::_redraw) Bug: homogeneous button width not honored if button size changes after creation. -uniform gridding option is used if tcl version >= 8.3. [Patch 2807147] by Koen Danckaert check-in: 1d83dc340a user: oehhar tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to ChangeLog.







1
2
3
4
5
6
7







2009-06-24 Harald Oehlmann  <[email protected]>

	* scrollframe.tcl (ScrollableFrame::create, ScrollableFrame::_resize,
	ScrollableFrame::_frameConfigure) fixed two issues:
	- Scrollbar activated even if not necessary
	  Fix: update scrolling reagion on configure event of the frame
	- Disfunction if the frame got to small to be on the current view
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
2009-06-25 Harald Oehlmann  <[email protected]>

	* combobox.tcl (ComboBox::getvalue et al) fixed bug: getvalue returned
	first apearence of current data instead of clicked index, which may not
	be the same if values is not unique. Additional variable _index(path)
	added to hold click index [Bug 1610965] reported by Martin Lemburg

2009-06-24 Harald Oehlmann  <[email protected]>

	* scrollframe.tcl (ScrollableFrame::create, ScrollableFrame::_resize,
	ScrollableFrame::_frameConfigure) fixed two issues:
	- Scrollbar activated even if not necessary
	  Fix: update scrolling reagion on configure event of the frame
	- Disfunction if the frame got to small to be on the current view
Changes to combobox.tcl.
1
2
3
4
5
6
7
8
9
10
11
# ----------------------------------------------------------------------------
#  combobox.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: combobox.tcl,v 1.38 2009/06/16 15:43:43 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ComboBox::create
#     - ComboBox::configure
#     - ComboBox::cget
#     - ComboBox::setvalue
#     - ComboBox::getvalue



|







1
2
3
4
5
6
7
8
9
10
11
# ----------------------------------------------------------------------------
#  combobox.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: combobox.tcl,v 1.39 2009/06/25 16:48:52 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ComboBox::create
#     - ComboBox::configure
#     - ComboBox::cget
#     - ComboBox::setvalue
#     - ComboBox::getvalue
49
50
51
52
53
54
55
56
57
58
59
60
61
62


63
64
65
66
67
68
69
    Widget::addmap ComboBox ArrowButton .a {
	-background {} -foreground {} -disabledforeground {} -state {}
    }

    Widget::syncoptions ComboBox Entry .e {-text {}}

    ::bind BwComboBox <FocusIn> [list after idle {BWidget::refocus %W %W.e}]
    ::bind BwComboBox <Destroy> [list Widget::destroy %W]

    ::bind ListBoxHotTrack <Motion> {
        %W selection clear 0 end
        %W activate @%x,%y
        %W selection set @%x,%y
    }


}


# ComboBox::create --
#
#	Create a combobox widget with the given options.
#







|






>
>







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    Widget::addmap ComboBox ArrowButton .a {
	-background {} -foreground {} -disabledforeground {} -state {}
    }

    Widget::syncoptions ComboBox Entry .e {-text {}}

    ::bind BwComboBox <FocusIn> [list after idle {BWidget::refocus %W %W.e}]
    ::bind BwComboBox <Destroy> [list ComboBox::_destroy %W]

    ::bind ListBoxHotTrack <Motion> {
        %W selection clear 0 end
        %W activate @%x,%y
        %W selection set @%x,%y
    }

    variable _index
}


# ComboBox::create --
#
#	Create a combobox widget with the given options.
#
150
151
152
153
154
155
156


157
158
159
160
161
162
163
    ## If we have images, we have to use a BWidget ListBox.
    set bw [Widget::cget $path -bwlistbox]
    if {[llength [Widget::cget $path -images]]} {
        Widget::configure $path [list -bwlistbox 1]
    } else {
        Widget::configure $path [list -bwlistbox $bw]
    }



    return [Widget::create ComboBox $path]
}


# ComboBox::configure --
#







>
>







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
    ## If we have images, we have to use a BWidget ListBox.
    set bw [Widget::cget $path -bwlistbox]
    if {[llength [Widget::cget $path -images]]} {
        Widget::configure $path [list -bwlistbox 1]
    } else {
        Widget::configure $path [list -bwlistbox $bw]
    }

    set ComboBox::_index($path) -1

    return [Widget::create ComboBox $path]
}


# ComboBox::configure --
#
291
292
293
294
295
296
297


298
299
300
301
302
303
304
}


# ----------------------------------------------------------------------------
#  Command ComboBox::setvalue
# ----------------------------------------------------------------------------
proc ComboBox::setvalue { path index } {


    set values [Widget::getMegawidgetOption $path -values]
    set value  [Entry::cget $path.e -text]
    switch -- $index {
        next {
            if { [set idx [lsearch -exact $values $value]] != -1 } {
                incr idx
            } else {







>
>







295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
}


# ----------------------------------------------------------------------------
#  Command ComboBox::setvalue
# ----------------------------------------------------------------------------
proc ComboBox::setvalue { path index } {
    variable _index

    set values [Widget::getMegawidgetOption $path -values]
    set value  [Entry::cget $path.e -text]
    switch -- $index {
        next {
            if { [set idx [lsearch -exact $values $value]] != -1 } {
                incr idx
            } else {
327
328
329
330
331
332
333

334
335
336
337
338
339
340
            } else {
                return -code error "bad index \"$index\""
            }
        }
    }
    if { $idx >= 0 && $idx < [llength $values] } {
        set newval [lindex $values $idx]

	Entry::configure $path.e -text $newval
        return 1
    }
    return 0
}









>







333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
            } else {
                return -code error "bad index \"$index\""
            }
        }
    }
    if { $idx >= 0 && $idx < [llength $values] } {
        set newval [lindex $values $idx]
        set _index($path) $idx
	Entry::configure $path.e -text $newval
        return 1
    }
    return 0
}


348
349
350
351
352
353
354

355
356








357
358
359
360
361
362
363
}


# ----------------------------------------------------------------------------
#  Command ComboBox::getvalue
# ----------------------------------------------------------------------------
proc ComboBox::getvalue { path } {

    set values [Widget::getMegawidgetOption $path -values]
    set value  [Entry::cget $path.e -text]









    return [lsearch -exact $values $value]
}


proc ComboBox::getlistbox { path } {
    _create_popup $path







>


>
>
>
>
>
>
>
>







355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
}


# ----------------------------------------------------------------------------
#  Command ComboBox::getvalue
# ----------------------------------------------------------------------------
proc ComboBox::getvalue { path } {
    variable _index
    set values [Widget::getMegawidgetOption $path -values]
    set value  [Entry::cget $path.e -text]
    # Check if an index was saved by the last setvalue operation
    # If this index still matches it is returned
    # This is necessary for the case when values is not unique
    if { $_index($path) >= 0 \
        && $_index($path) < [llength $values] \
        && $value eq [lindex $values $_index($path)]} {
        return $_index($path)
    }

    return [lsearch -exact $values $value]
}


proc ComboBox::getlistbox { path } {
    _create_popup $path
839
840
841
842
843
844
845
846








    }

    if {$x >= 0} {
        $path.shell.listb selection clear 0 end
        $path.shell.listb selection set $x
        $path.shell.listb see $x
    }
}
















>
>
>
>
>
>
>
>
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
    }

    if {$x >= 0} {
        $path.shell.listb selection clear 0 end
        $path.shell.listb selection set $x
        $path.shell.listb see $x
    }
}
# ------------------------------------------------------------------------------
#  Command ComboBox::_destroy
# ------------------------------------------------------------------------------
proc ComboBox::_destroy { path } {
    variable _index
    Widget::destroy $path
    unset _index($path)
}