# entry.tcl -- # # This file defines the default bindings for Tk entry widgets and provides # procedures that help in implementing those bindings. # # @(#) entry.tcl 1.36 95/06/17 17:47:29 # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1995 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # #------------------------------------------------------------------------- # Elements of tkPriv that are used in this file: # # afterId - If non-null, it means that auto-scanning is underway # and it gives the "after" id for the next auto-scan # command to be executed. # mouseMoved - Non-zero means the mouse has moved a significant # amount since the button went down (so, for example, # start dragging out a selection). # pressX - X-coordinate at which the mouse button was pressed. # selectMode - The style of selection currently underway: # char, word, or line. # x, y - Last known mouse coordinates for scanning # and auto-scanning. #------------------------------------------------------------------------- # tkEntryClipboardKeysyms -- # This procedure is invoked to identify the keys that correspond to # the "copy", "cut", and "paste" functions for the clipboard. # # Arguments: # copy - Name of the key (keysym name plus modifiers, if any, # such as "Meta-y") used for the copy operation. # cut - Name of the key used for the cut operation. # paste - Name of the key used for the paste operation. proc tkEntryClipboardKeysyms {copy cut paste} { bind Entry <$copy> { if {[selection own -displayof %W] == "%W"} { clipboard clear -displayof %W catch { clipboard append -displayof %W [selection get -displayof %W] } } } bind Entry <$cut> { if {[selection own -displayof %W] == "%W"} { clipboard clear -displayof %W catch { clipboard append -displayof %W [selection get -displayof %W] %W delete sel.first sel.last } } } bind Entry <$paste> { catch { %W insert insert [selection get -displayof %W \ -selection CLIPBOARD] } } } #------------------------------------------------------------------------- # The code below creates the default class bindings for entries. #------------------------------------------------------------------------- # Standard Motif bindings: bind Entry <1> { tkEntryButton1 %W %x %W selection clear } bind Entry { set tkPriv(x) %x tkEntryMouseSelect %W %x } bind Entry { set tkPriv(selectMode) word tkEntryMouseSelect %W %x catch {%W icursor sel.first} } bind Entry { set tkPriv(selectMode) line tkEntryMouseSelect %W %x %W icursor 0 } bind Entry { set tkPriv(selectMode) char %W selection adjust @%x } bind Entry { set tkPriv(selectMode) word tkEntryMouseSelect %W %x } bind Entry { set tkPriv(selectMode) line tkEntryMouseSelect %W %x } bind Entry { set tkPriv(x) %x tkEntryAutoScan %W } bind Entry { tkCancelRepeat } bind Entry { tkCancelRepeat } bind Entry { %W icursor @%x } bind Entry { tkEntrySetCursor %W [expr [%W index insert] - 1] } bind Entry { tkEntrySetCursor %W [expr [%W index insert] + 1] } bind Entry { tkEntryKeySelect %W [expr [%W index insert] - 1] tkEntrySeeInsert %W } bind Entry { tkEntryKeySelect %W [expr [%W index insert] + 1] tkEntrySeeInsert %W } bind Entry { tkEntrySetCursor %W \ [string wordstart [%W get] [expr [%W index insert] - 1]] } bind Entry { tkEntrySetCursor %W [string wordend [%W get] [%W index insert]] } bind Entry { tkEntryKeySelect %W \ [string wordstart [%W get] [expr [%W index insert] - 1]] tkEntrySeeInsert %W } bind Entry { tkEntryKeySelect %W [string wordend [%W get] [%W index insert]] tkEntrySeeInsert %W } bind Entry { tkEntrySetCursor %W 0 } bind Entry { tkEntryKeySelect %W 0 tkEntrySeeInsert %W } bind Entry { tkEntrySetCursor %W end } bind Entry { tkEntryKeySelect %W end tkEntrySeeInsert %W } bind Entry { if [%W selection present] { %W delete sel.first sel.last } else { %W delete insert } } bind Entry { tkEntryBackspace %W } bind Entry { %W selection from insert } bind Entry