Remove error
I have option for selection of node (*createmarkpanel) followed by set of operations. If, i am not selecting any node, while execution of command, I want to exit from command instead of throwing errors. please help me to sort this out.
Answers
-
Hi Jouher,
*createmarkpanel nodes 1 'Please select nodes';
if {[hm_marklength nodes 1] > 0} {
*nodemarkaddtempmark 1;
} else {
tk_messageBox -message '0 nodes selected' -icon error;
}Or You can use 'catch' command.
https://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm
Thanks,
Imoto
0 -
Thanks @Imoto ,
But, If i select any node, then press esc it wont work. similarly for string too, if I type name and instead of proceed, if i press esc key, it will proceed further.
Please help me to solve this too.
0 -
Hi Jouher,
so you want : press ESC => will NOT proceed, don't you?
I had the code
0 -
Altair Forum User said:
Hi Jouher,
so you want : press ESC => will NOT proceed, don't you?
I had the code
Yes, @tinh
0 -
Hi Jouher,
You can add the bind for Escape key.
proc ESCkeyClearAll {args} {
hm_markclearall 1;
hm_markclearall 2;
}
bind . <Escape> ESCkeyClearAll
*createmarkpanel nodes 1 'Please select nodes';
if {[hm_marklength nodes 1] > 0} {
*nodemarkaddtempmark 1;
} else {
tk_messageBox -message '0 node selected' -icon error;
}Thanks,
Imoto0 -
Altair Forum User said:
Hi Jouher,
You can add the bind for Escape key.
proc ESCkeyClearAll {args} {
hm_markclearall 1;
hm_markclearall 2;
}
bind . <Escape> ESCkeyClearAll
*createmarkpanel nodes 1 'Please select nodes';
if {[hm_marklength nodes 1] > 0} {
*nodemarkaddtempmark 1;
} else {
tk_messageBox -message '0 node selected' -icon error;
}Thanks,
ImotoIts not working
0 -
Hi
we should not bind a script to '.' toplevel, because it will trigger every widgets
the main widget receives ESC key to exit panel is .hmContainer
0 -
Thanks Tinh,
bind .hmContainer <Escape> {hm_markclearall 1; hm_markclearall 2; hm_notifykeydown %N %k;}
0 -
I wrote a proc like this:
proc p_SelectMark {EntityType MarkId args} {
#this binding code can be set once at level #0, but i embed here, so this proc is working everytime
if {![string match '*set ::v_PressEsc 1*' [bind .hmContainer <Key-Escape>]]} {
bind .hmContainer <Key-Escape> {+set ::v_PressEsc 1}
}
if {![hm_info functionlock]} {
set ::v_PressEsc 0
*createmarkpanel $EntityType $MarkId $args
if {$::v_PressEsc} {
*clearmark $EntityType $MarkId
}
hm_getmark $EntityType $MarkId
}
}
0