Tk Source Code

Artifact [12416151]
Login

Artifact 12416151cf0285ae9a274b64ee4b0184ba9f336f:

Attachment "ListboxBeginSelect.tcl" to ticket [960391ff] added by eriklns 2004-05-27 00:15:30.
# ::tk::ListboxBeginSelect --
#
# This procedure is typically invoked on button-1 presses.  It begins
# the process of making a selection in the listbox.  Its exact behavior
# depends on the selection mode currently in effect for the listbox;
# see the Motif documentation for details.
#
# Arguments:
# w -		The listbox widget.
# el -		The element for the selection operation (typically the
#		one under the pointer).  Must be in numerical form.
#
# Improved display handling
# 26-May-2004, Erik Leunissen

proc ::tk::ListboxBeginSelect {w el} {
    variable ::tk::Priv
    if {[string equal [$w cget -selectmode] "multiple"]} {
        if {[$w selection includes $el]} {
            $w selection clear $el
        } else {
            $w selection set $el
        }
    } else {
        $w selection anchor $el
        set Priv(listboxPrev) $el
        if {[$w selection includes $el]} {
            # Deselect two separate ranges adjacent to $el,
            # in order to prevent display flicker of $el.
            $w selection clear 0 [incr el -1]
            $w selection clear [incr el 2] end
        } else {
            $w selection clear 0 end
            $w selection set $el
        }
        set Priv(listboxSelection) {}
    }
    event generate $w <<ListboxSelect>>
}

# EOF