| Ticket UUID: | 723856 | |||
| Title: | cannot use menu names with spaces | |||
| Type: | Bug | Version: | obsolete: 8.4.2 | |
| Submitter: | markgsaye | Created on: | 2003-04-18 19:37:55 | |
| Subsystem: | 12. Unix Menus | Assigned To: | tmh | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2003-11-13 23:07:46 | |
| Resolution: | Fixed | Closed By: | hobbs | |
| Closed on: | 2003-11-11 23:42:52 | |||
| Description: |
Consider the following code:
set W {.menu test}
toplevel $W
set menu "$W.menu"
menu $menu -relief flat -bd 0
$W configure -menu $menu
$menu add cascade -label File -underline 0 -menu
$menu.file
menu $menu.file
$menu.file add command -label Exit -command exit
Note that if there is a space anywhere in the menu
name, it causes the following error when posting the menu:
invalid command name ".menu"
while executing
".menu test.#menu test#menu.#menu test#menu#file post
593 57"
invoked from within
"$menu postcascade active"
(procedure "tk::MenuMotion" line 15)
invoked from within
"tk::MenuMotion .menu\ test.#menu\ test#menu 18 17 256"
(command bound to event)
I *believe* that the problem is in the use of
Tcl_VarEval in line 1001 of tk8.4.2/generic/tkMenuDraw.c :
result = Tcl_VarEval(interp, name, " post ", string,
(char *) NULL);
which does not account for spaces. I totally hacked the
following replacement line:
result = Tcl_VarEval(interp, "{", name, "} post ",
string, (char *) NULL);
which fixes the problem, but I'm sure there's a proper
way to do this. Line 978 also suffers from this problem
("unpost"), and I expect there may be other places too.
What's the correct way to fix this? (I'm trying to
learn more C) Thanks!
| |||
| User Comments: |
dkf added on 2003-11-13 23:07:46:
Logged In: YES user_id=79902 Rewritten :^) hobbs added on 2003-11-12 06:42:52: Logged In: YES
user_id=72656
fixed with the {} for 8.4.5 and 8.5a0 until someone rewrites
for Tcl_Obj.
vincentdarley added on 2003-09-09 00:50:30: Logged In: YES user_id=32170 There is a similar bug in the text widget (x,yscrollcmd), which happens to have been fixed in the tip155 patch (through use of Tcl_EvalObjEx). Is there any way to have a widget configuration option (e.g. these callbacks) actually be a Tcl_Obj* instead of a char*? dkf added on 2003-09-07 23:07:33: Logged In: YES user_id=79902 Looks to me like TkPostSubmenu should be using Tcl_EvalObjv instead of Tcl_VarEval. tmh added on 2003-09-03 03:41:06: Logged In: YES user_id=92123 Confirmed. By my reading there is no way Tcl_VarEval will handle a name parameter with a space in it. It seems that most of the other widgets have been converted to Tcl_Obj type invocation calls. NOTE: This is also an error in tkEntry.c when evaluating scrollCmd for entry widgets with spaces in the name. tkEntry.c: code = Tcl_VarEval(interp, entryPtr->scrollCmd, args, (char *) NULL); This is likely a problem with the scrollCmd evaluation in the listbox, canvas, and text widgets as well. | |||