# entry.tcl -- # # This file defines the default bindings for Tk entry widgets and provides # procedures that help in implementing those bindings. # # RCS: @(#) $Id: entry.tcl,v 1.1.4.2 1998/09/30 02:17:32 stanton Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 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. #------------------------------------------------------------------------- #------------------------------------------------------------------------- # The code below creates the default class bindings for entries. #------------------------------------------------------------------------- bind Entry <> { if {![catch {set data [string range [%W get] [%W index sel.first]\ [expr {[%W index sel.last] - 1}]]}]} { clipboard clear -displayof %W clipboard append -displayof %W $data %W delete sel.first sel.last } } bind Entry <> { if {![catch {set data [string range [%W get] [%W index sel.first]\ [expr {[%W index sel.last] - 1}]]}]} { clipboard clear -displayof %W clipboard append -displayof %W $data } } bind Entry <> { global tcl_platform catch { if {"$tcl_platform(platform)" != "unix"} { catch { %W delete sel.first sel.last } } %W insert insert [selection get -displayof %W -selection CLIPBOARD] tkEntrySeeInsert %W } } bind Entry <> { %W delete sel.first sel.last } bind Entry <> { if {!$tkPriv(mouseMoved) || $tk_strictMotif} { tkEntryPaste %W %x } } # 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 [tkEntryPreviousWord %W insert] } bind Entry { tkEntrySetCursor %W [tkEntryNextWord %W insert] } bind Entry { tkEntryKeySelect %W [tkEntryPreviousWord %W insert] tkEntrySeeInsert %W } bind Entry { tkEntryKeySelect %W [tkEntryNextWord %W 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