# spinbox.tcl -- # # This file defines the default bindings for Tk spinbox widgets and provides # procedures that help in implementing those bindings. # # RCS: @(#) $Id: spinbox.tcl,v 1.3 2001/08/01 16:21:11 dgp Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. # Copyright (c) 1999-2000 Jeffrey Hobbs # Copyright (c) 2000 Ajuba Solutions # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # #------------------------------------------------------------------------- # Elements of tk::Priv 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. # data - Used for Cut and Copy #------------------------------------------------------------------------- # Initialize namespace namespace eval ::tk::spinbox {} #------------------------------------------------------------------------- # The code below creates the default class bindings for entries. #------------------------------------------------------------------------- bind Spinbox <> { if {![catch {::tk::spinbox::GetSelection %W} tk::Priv(data)]} { clipboard clear -displayof %W clipboard append -displayof %W $tk::Priv(data) %W delete sel.first sel.last unset tk::Priv(data) } } bind Spinbox <> { if {![catch {::tk::spinbox::GetSelection %W} tk::Priv(data)]} { clipboard clear -displayof %W clipboard append -displayof %W $tk::Priv(data) unset tk::Priv(data) } } bind Spinbox <> { global tcl_platform catch { if {[string compare $tcl_platform(platform) "unix"]} { catch { %W delete sel.first sel.last } } %W insert insert [::tk::GetSelection %W CLIPBOARD] ::tk::spinbox::SeeInsert %W } } bind Spinbox <> { %W delete sel.first sel.last } bind Spinbox <> { if {!$tk::Priv(mouseMoved) || $tk_strictMotif} { ::tk::spinbox::Paste %W %x } } # Standard Motif bindings: bind Spinbox <1> { ::tk::spinbox::ButtonDown %W %x %y } bind Spinbox { ::tk::spinbox::Motion %W %x %y } bind Spinbox { set tk::Priv(selectMode) word ::tk::spinbox::MouseSelect %W %x sel.first } bind Spinbox { set tk::Priv(selectMode) line ::tk::spinbox::MouseSelect %W %x 0 } bind Spinbox { set tk::Priv(selectMode) char %W selection adjust @%x } bind Spinbox { set tk::Priv(selectMode) word ::tk::spinbox::MouseSelect %W %x } bind Spinbox { set tk::Priv(selectMode) line ::tk::spinbox::MouseSelect %W %x } bind Spinbox { set tk::Priv(x) %x ::tk::spinbox::AutoScan %W } bind Spinbox { tk::CancelRepeat } bind Spinbox { ::tk::spinbox::ButtonUp %W %x %y } bind Spinbox { %W icursor @%x } bind Spinbox { %W invoke buttonup } bind Spinbox { %W invoke buttondown } bind Spinbox { ::tk::spinbox::SetCursor %W [expr {[%W index insert] - 1}] } bind Spinbox { ::tk::spinbox::SetCursor %W [expr {[%W index insert] + 1}] } bind Spinbox { ::tk::spinbox::KeySelect %W [expr {[%W index insert] - 1}] ::tk::spinbox::SeeInsert %W } bind Spinbox { ::tk::spinbox::KeySelect %W [expr {[%W index insert] + 1}] ::tk::spinbox::SeeInsert %W } bind Spinbox { ::tk::spinbox::SetCursor %W [::tk::spinbox::PreviousWord %W insert] } bind Spinbox { ::tk::spinbox::SetCursor %W [::tk::spinbox::NextWord %W insert] } bind Spinbox { ::tk::spinbox::KeySelect %W [::tk::spinbox::PreviousWord %W insert] ::tk::spinbox::SeeInsert %W } bind Spinbox { ::tk::spinbox::KeySelect %W [::tk::spinbox::NextWord %W insert] ::tk::spinbox::SeeInsert %W } bind Spinbox { ::tk::spinbox::SetCursor %W 0 } bind Spinbox { ::tk::spinbox::KeySelect %W 0 ::tk::spinbox::SeeInsert %W } bind Spinbox { ::tk::spinbox::SetCursor %W end } bind Spinbox { ::tk::spinbox::KeySelect %W end ::tk::spinbox::SeeInsert %W } bind Spinbox { if {[%W selection present]} { %W delete sel.first sel.last } else { %W delete insert } } bind Spinbox { ::tk::spinbox::Backspace %W } bind Spinbox { %W selection from insert } bind Spinbox