From ac1be4e1b207b8ce8a1986b99d476959cf7eb1c0 Mon Sep 17 00:00:00 2001 From: miljenko Date: Mon, 26 Mar 2007 11:32:28 +0000 Subject: [PATCH] Undo/Redo disabled in Edit menu if there is nothing to undo or redo. Fixed undo for "Allign to grid" Bug found by: Submitted by: Requested by: Reviewed by: Approved by: Obtained from: --- editor.tcl | 15 ++++++++++++++- exec.tcl | 13 +++++++++++-- initgui.tcl | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/editor.tcl b/editor.tcl index ef8b485..9362e6b 100755 --- a/editor.tcl +++ b/editor.tcl @@ -149,6 +149,9 @@ proc updateUndoLog {} { set t_undolog "" dumpCfg string t_undolog incr undolevel + if { $undolevel == 1 } { + .menubar.edit entryconfigure "Undo" -state normal + } set undolog($undolevel) $t_undolog set redolevel $undolevel set changed 0 @@ -169,7 +172,11 @@ proc undo {} { global undolevel undolog oper_mode if {$oper_mode == "edit" && $undolevel > 0} { + .menubar.edit entryconfigure "Redo" -state normal incr undolevel -1 + if { $undolevel == 0 } { + .menubar.edit entryconfigure "Undo" -state disabled + } .c config -cursor watch loadCfg $undolog($undolevel) switchCanvas none @@ -193,6 +200,12 @@ proc redo {} { if {$oper_mode == "edit" && $redolevel > $undolevel} { incr undolevel + if { $undolevel == 1 } { + .menubar.edit entryconfigure "Undo" -state normal + } + if {$redolevel <= $undolevel} { + .menubar.edit entryconfigure "Redo" -state disabled + } .c config -cursor watch loadCfg $undolog($undolevel) switchCanvas none @@ -2608,7 +2621,7 @@ proc deleteSelection { } { proc align2grid {} { - global sizex sizey grid zoom + global sizex sizey grid zoom changed set node_objects [.c find withtag node] if { [llength $node_objects] == 0 } { diff --git a/exec.tcl b/exec.tcl index 5ce9693..560b7f7 100755 --- a/exec.tcl +++ b/exec.tcl @@ -141,6 +141,7 @@ proc setOperMode { mode } { global oper_mode activetool node_list global nmbufs nmbclusters global editor_only remote_exec execSock + global undolevel redolevel if { $mode == "exec" } { ;# let's try something, sockets should be opened nexec id -u @@ -214,8 +215,16 @@ proc setOperMode { mode } { .menubar.experiment entryconfigure "Execute" -state normal } .menubar.experiment entryconfigure "Terminate" -state disabled - .menubar.edit entryconfigure "Undo" -state normal - .menubar.edit entryconfigure "Redo" -state normal + if { $undolevel > 0 } { + .menubar.edit entryconfigure "Undo" -state normal + } else { + .menubar.edit entryconfigure "Undo" -state disabled + } + if { $redolevel > $undolevel } { + .menubar.edit entryconfigure "Redo" -state normal + } else { + .menubar.edit entryconfigure "Redo" -state disabled + } set oper_mode edit remoteClose } diff --git a/initgui.tcl b/initgui.tcl index c470a76..b018e12 100755 --- a/initgui.tcl +++ b/initgui.tcl @@ -212,10 +212,10 @@ bind . "fileSaveDialogBox" # menu .menubar.edit -tearoff 0 .menubar.edit add command -label "Undo" -underline 0 \ - -accelerator "Ctrl+Z" -command undo + -accelerator "Ctrl+Z" -command undo -state disabled bind . undo .menubar.edit add command -label "Redo" -underline 0 \ - -accelerator "Ctrl+Y" -command redo + -accelerator "Ctrl+Y" -command redo -state disabled bind . redo .menubar.edit add separator .menubar.edit add command -label "Select all" \ -- 2.39.5