# listbox.tcl -- # # This file defines the default bindings for Tk listbox widgets # and provides procedures that help in implementing those bindings. # # RCS: @(#) $Id: listbox.tcl,v 1.13.2.2 2004/02/17 07:17:17 das Exp $ # # Copyright (c) 1994 The Regents of the University of California. # Copyright (c) 1994-1995 Sun Microsystems, Inc. # Copyright (c) 1998 by Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. #-------------------------------------------------------------------------- # tk::Priv elements used in this file: # # afterId - Token returned by "after" for autoscanning. # listboxPrev - The last element to be selected or deselected # during a selection operation. # listboxSelection - All of the items that were selected before the # current selection operation (such as a mouse # drag) started; used to cancel an operation. #-------------------------------------------------------------------------- #------------------------------------------------------------------------- # The code below creates the default class bindings for listboxes. #------------------------------------------------------------------------- # Note: the check for existence of %W below is because this binding # is sometimes invoked after a window has been deleted (e.g. because # there is a double-click binding on the widget that deletes it). Users # can put "break"s in their bindings to avoid the error, but this check # makes that unnecessary. bind Listbox <1> { if {[winfo exists %W]} { tk::ListboxBeginSelect %W [%W index @%x,%y] } } # Ignore double clicks so that users can define their own behaviors. # Among other things, this prevents errors if the user deletes the # listbox on a double click. bind Listbox { # Empty script } bind Listbox { set tk::Priv(x) %x set tk::Priv(y) %y tk::ListboxMotion %W [%W index @%x,%y] } bind Listbox { tk::CancelRepeat %W activate @%x,%y } bind Listbox { tk::ListboxBeginExtend %W [%W index @%x,%y] } bind Listbox { tk::ListboxBeginToggle %W [%W index @%x,%y] } bind Listbox { set tk::Priv(x) %x set tk::Priv(y) %y tk::ListboxAutoScan %W } bind Listbox { tk::CancelRepeat } bind Listbox { tk::ListboxUpDown %W -1 } bind Listbox { tk::ListboxExtendUpDown %W -1 } bind Listbox { tk::ListboxUpDown %W 1 } bind Listbox { tk::ListboxExtendUpDown %W 1 } bind Listbox { %W xview scroll -1 units } bind Listbox { %W xview scroll -1 pages } bind Listbox { %W xview scroll 1 units } bind Listbox { %W xview scroll 1 pages } bind Listbox { %W yview scroll -1 pages %W activate @0,0 } bind Listbox { %W yview scroll 1 pages %W activate @0,0 } bind Listbox { %W xview scroll -1 pages } bind Listbox { %W xview scroll 1 pages } bind Listbox { %W xview moveto 0 } bind Listbox { %W xview moveto 1 } bind Listbox { %W activate 0 %W see 0 %W selection clear 0 end %W selection set 0 event generate %W <> } bind Listbox { tk::ListboxDataExtend %W 0 } bind Listbox { %W activate end %W see end %W selection clear 0 end %W selection set end event generate %W <> } bind Listbox { tk::ListboxDataExtend %W [%W index end] } bind Listbox <> { if {[string equal [selection own -displayof %W] "%W"]} { clipboard clear -displayof %W clipboard append -displayof %W [selection get -displayof %W] } } bind Listbox { tk::ListboxBeginSelect %W [%W index active] } bind Listbox