# 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.11 2000/03/24 19:38:57 ericm 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. #-------------------------------------------------------------------------- # tkPriv 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]} { tkListboxBeginSelect %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 tkPriv(x) %x set tkPriv(y) %y tkListboxMotion %W [%W index @%x,%y] } bind Listbox { tkCancelRepeat %W activate @%x,%y } bind Listbox { tkListboxBeginExtend %W [%W index @%x,%y] } bind Listbox { tkListboxBeginToggle %W [%W index @%x,%y] } bind Listbox { set tkPriv(x) %x set tkPriv(y) %y tkListboxAutoScan %W } bind Listbox { tkCancelRepeat } bind Listbox { tkListboxUpDown %W -1 } bind Listbox { tkListboxExtendUpDown %W -1 } bind Listbox { tkListboxUpDown %W 1 } bind Listbox { tkListboxExtendUpDown %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 { tkListboxDataExtend %W 0 } bind Listbox { %W activate end %W see end %W selection clear 0 end %W selection set end event generate %W <> } bind Listbox { tkListboxDataExtend %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 { tkListboxBeginSelect %W [%W index active] } bind Listbox