From a4c9d6fa73871a9e12d1e4a056401c7fc7339b87 Mon Sep 17 00:00:00 2001 From: sls Date: Tue, 7 Feb 1995 08:30:22 +0000 Subject: [PATCH] Add menu entries. Allow detaching of value. --- value.tcl | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/value.tcl b/value.tcl index e3c9ae0..a8656a0 100644 --- a/value.tcl +++ b/value.tcl @@ -2,6 +2,8 @@ # $Id$ # +set value_priv(counter) -1 + proc value_no_filter {text} { return $text } @@ -12,12 +14,13 @@ widget value { param main param savehist 15 member hist_no 0 + member send_filter value_no_filter method create {} { $self config -bd 2 -relief raised -highlightthickness 0 pack [frame $self.title] -side top -fill x pack [label $self.title.l -text "Value: "] -side left menubutton $self.title.vname -anchor w -menu $self.title.vname.m \ - -bd 0 + -bd 0 -state disabled menu $self.title.vname.m -postcommand "$self fill_vname_menu" pack $self.title.vname -fill x scrollbar $self.sb -relief sunken -bd 1 -command "$self.t yview" @@ -25,6 +28,13 @@ widget value { pack $self.sb -side right -fill y pack $self.t -side right -fill both -expand 1 bind $self.t "$self send_value" + set m [$slot(main) add_menu Value] + $m add command -label "Send Value" -command "$self send_value" + $m add command -label "Save Value..." -state disabled + $m add command -label "Load Value..." -state disabled + $m add command -label "Detach Window" -command "$self detach" + bind $self.t \ + "if {\[focus -lastfor $self\] != \"$self\"} { $slot(main) status \"C-x C-s to send value\" }; continue" } method reconfig {} { $self.t config -width $slot(width) -height $slot(height) @@ -32,7 +42,7 @@ widget value { method set_value {name value redo_command} { $self.t delete 1.0 end $self.t insert 1.0 $value - $self.title.vname config -text $name + $self.title.vname config -text $name -state normal set slot(history.[incr slot(hist_no)]) [list $name $redo_command] if {($slot(hist_no) - $slot(savehist)) > 0} { unset slot(history.[expr $slot(hist_no)-$slot(savehist)]) @@ -57,4 +67,13 @@ widget value { [eval $slot(send_filter) [list [$self.t get 1.0 end]]] $slot(main) status "Value sent" } + method detach {} { + set w [tkinspect_create_main_window \ + -default_lists {} \ + -target [$slot(main) cget -target]] + $w.value copy $self + } + method copy {v} { + $self.t insert 1.0 [$v.t get 1.0 end] + } } -- 2.23.0