Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/bind?V=94
QUERY_STRINGV=94
CONTENT_TYPE
DOCUMENT_URI/revision/bind
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.130.176
REMOTE_PORT10460
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR18.221.141.44
HTTP_CF_RAY87b1496d2ed72bab-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP18.221.141.44
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

wrong # args: should be "string replace string first last ?string?"

-code

1

-level

0

-errorstack

INNER {returnImm {wrong # args: should be "string replace string first last ?string?"} {}} CALL {my render_wikit bind \['''`\[http://www.tcl.tk/man/tcl/TkCmd/bind.htm%|%bind\]`'''\],\ a\ \[Tk\n\[script%|%scripts\].\n\[scripts\].\n\n\n**\ Documentation\ **\n*\ See\ Also\ **\n\n\ \ \ \[Bindings\ and\ why\ they\ are\ important\]:\ \ \ \n\n\ \ \ \[Bindings\ and\ variable\ substitution\]:\ \ \ \n\n\ \ \ \[Disable\ autorepeat\ under\ X11\]:\ \ \ \n\n\ \ \ \[mousewheel\]\ bindings:\ \ \ \n\n\ \ \ \[binding\ to\ a\ single\ mouse\ click\]:\ \ \ \n\n\ \ \ \[Key-press\ names\]:\ \ \ \n\n\ \ \ \[Portable\ keystate\]:\ \ \ \n\n\n\n\n\ \ \ \[http://www.tcl.tk/man/tcl/TkCmd/bind.htm%|%official\ reference\]:\ \ \ \n\n\ \ \ `\[keysyms\]`:\ \ \ the\ keyboard\ symbols\ to\ which\ one\ can\ potentially\ bind\ things.\ \ Of\ course,\ the\ specific\ keysyms\ available\ to\ you\ on\ any\ particular\ platform/hardware\ depend\ on\ factors\ outside\ of\ Tk's\ control.\ \ (See\ below\ for\ a\ simple\ script\ for\ determining\ what\ the\ specific\ keysym\ for\ a\ character\ is.)\n\ \ \ \[keysyms\]:\ \ \ the\ keyboard\ symbols\ to\ which\ one\ can\ potentially\ bind\ things.\ \ Of\ course,\ the\ specific\ keysyms\ available\ to\ you\ on\ any\ particular\ platform/hardware\ depend\ on\ factors\ outside\ of\ Tk's\ control.\ \ (See\ below\ for\ a\ simple\ script\ for\ determining\ what\ the\ specific\ keysym\ for\ a\ character\ is.)\n\n\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag''\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag\ sequence''\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag\ sequence\ script''\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag\ sequence\ '''''+'''''script''\n\n\n\n**\ Description\ **\n\n`bind`\ (part\ of\ \[Tk\])\ is\ used\ to\ associate\ Tcl\ commands\ to\ execute\ upon\nthe\ press\ of\ specific\ keys.\ \ Also,\ `bind`\ may\ be\ driven\ by\ other\ events,\ both\nthe\ press\ of\ specific\ keys.\ \ Also,\ bind\ may\ be\ driven\ by\ other\ events,\ both\ndocumentation\ for\ specific\ details.\n\n''tag''\ is\ formally\ a\ `\[bindtags\]`\ tag,\ but\ for\ most\ user\ code\ it\ is\ best\ to\n''tag''\ is\ formally\ a\ \[bindtags\]\ tag,\ but\ for\ most\ user\ code\ it\ is\ best\ to\nomitted,\ `bind`\ returns\ what\ bindings\ are\ set\ on\ ''tag''.\ If\ ''script''\ is\nomitted,\ '''bind'''\ returns\ what\ bindings\ are\ set\ on\ ''tag''.\ If\ ''script''\ is\n“'''+'''”)\ the\ binding\ script,\ and\ if\ ''script''\ is\ omitted\ (but\ ''sequence''\nis\ given)\ then\ the\ current\ binding\ script\ is\ returned.\n\nKeyboard\ symbols\ are\ the\ Tk\ values\ associated\ with\ particular\ sequences\ of\nkeyboard\ keys\ that\ one\ can\ press,\ such\ as\ Shift,\ or\ A\ or\ special\ function\ keys\nsuch\ as\ Page\ Up,\ etc.\n\n\n\n**\ Examples\ **\n\n\ \ \ \[Only\ in\ tcl...\]:\ \ \ A\ nice\ simple\ example\ of\ `bind`\ in\ action\n\ \ \ \[Vogel\ spiral\]:\ \ \ uses\ \[\[`\[apply\]`\]\ as\ the\ script\ for\ \[\[`\[bind\]`\]\n\ \ \ \[Salvatore\ Sanfilippo\]:\ \ \ has\ an\ example\ on\ his\ page\ of\ using\ a\ keyboard\ n\ \"raw\"\ mode\n\n\nIf\ you\ are\ looking\ for\ the\ \[eggdrop\]\ `bind`\ command,\ try\ \[http://www.eggheads.org/support/egghtml/1.6.17/tcl-commands.html#bind%|%bind%|%\]\nIf\ you\ are\ looking\ for\ the\ \[eggdrop\]\ bind\ command,\ try\ \[http://www.eggheads.org/support/egghtml/1.6.17/tcl-commands.html#bind%|%bind%|%\]\n\n<<discussion>>\n**\ Discussion\ **\n\n\n**\ Unanswered\ Questions\ **\n\n\n'''Question''':\ Is\ there\ an\ introspective\ method\ that\ a\ Tk\ application\ can\ndetermine\ whether\ a\ keysym\ is\ currently\ available\ for\ it\ to\ use?\n\n\n\n**\ Answered\ Questions\ **\n\n\ \ \ *\ \[Moving\ Canvas\ Window\ Items\ -\ Can\ someone\ tell\ me\ what's\ going\ on\ here?\]\n\n\n**\ `bind`\ Syntax\ Example\ **\n**\ \[\[`bind`\]\ Syntax\ Example\ **\n\[RS\]\ writes\ on\ comp.lang.tcl:\ The\ `bind`\ syntax\ is\ actually\ very\ easy.\ With\ x\ set\n\[RS\]\ writes\ on\ comp.lang.tcl:\ The\ bind\ syntax\ is\ actually\ very\ easy.\ With\ x\ set\n\n======\nbind\ \$x\n======\n\nto\ get\ a\ list\ of\ defined\ bindings.\ This\ list\ contains\ <Key-Prior>\ which\ is\ the\ncorrect\ name\ for\ the\ Page\ Up\ key.\ To\ see\ what\ it\ is\ bound\ to,\ call\n\n======\nbind\ \$x\ <Key-Prior>\n======\n\nTo\ mirror\ this\ binding\ to\ another\ event,\ make\ that\n\n======\nbind\ \$x\ <Control-r>\ \[bind\ \$x\ <Key-Prior>\]\n======\n\nlike\ you\ tried,\ just\ with\ the\ incorrect\ name.\ BTW,\ you\ normally\ need\ not\ninclude\ variable\ names\ in\ braces\ -\ only\ if\ they\ contain\ characters\ other\ than\n`A-Z\ a-z\ 0-9\ _`.\n\n\n\n**\ Finding\ keysyms\ ***\n\n\[KBK\]:\ You\ can\ find\ the\ keysym\ for\ a\ key\ on\ an\ unfamiliar\ keyboard\ by\ running\n\[KBK\]\ -\ You\ can\ find\ the\ keysym\ for\ a\ key\ on\ an\ unfamiliar\ keyboard\ by\ running\n\n======\nbind\ .\ <KeyPress>\ \{puts\ %K\}\ \;\ focus\ .\n======\n\ndirecting\ focus\ at\ the\ (empty)\ ''wish''\ window,\ and\ touching\ the\ key\ in\nquestion.\ \ On\ Windows,\ you'll\ need\ to\ add\n\n======\nconsole\ show\n======\n\nto\ the\ script\ so\ that\ you\ can\ see\ its\ output.\n\n\[Arjen\ Markus\]:\ You\ may\ also\ put\ up\ a\ text\ widget\ and\ display\ the\ keysym\ by\ the\nfollowing\ script:\n\n======\nbind\ .textwidget\ <KeyPress>\ \{\ %W\ insert\ end\ \"%K\\n\"\ \}\nfocus\ .textwidget\n======\n\n\n**\ Specifying\ a\ Key\ to\ `bind`\ **\n**\ Specifying\ a\ Key\ to\ Bind\ **\n\[Arjen\ Markus\]:\ There\ are\ several\ ways\ to\ define\ a\ specific\ key,\ for\ instance:\n\[Arjen\ Markus\]\ There\ are\ several\ ways\ to\ define\ a\ specific\ key,\ for\ instance:\n======\n<Key-keysym>\n<KeyPress-keysym>\n<KeyRelease-keysym>\ (subtle\ differences\ here!)\n<keysym>\n<A>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (if\ the\ character\ is\ plain\ ASCII)\n======\n\nFor\ a\ space,\ you\ will\ need\ to\ use:\n\n======\n<Key-space>\n======\n\nanything\ else\ seems\ to\ give\ problems.\n\nAlso\ note\ that\ keysyms\ are\ case-sensitive:\ \"Down\"\ for\ the\ downward\ arrow\ and\n\"space\"\ for\ a\ space\ (\"down\"\ and\ \"Space\"\ do\ ''not''\ work\;\ quotation\ marks\ for\nconvenience\ only)\n\n\n\n**\ `bind`\ to\ a\ Mouse\ Action\ **\n**\ \[\[`bind`\]\ to\ a\ Mouse\ Action\ **\n\[LV\]:\ If\ you\ are\ wanting\ to\ `bind`\ actions\ to\ a\ mouse\ button\ action,\ rather\ than\n\[LV\]:\ If\ you\ are\ wanting\ to\ bind\ actions\ to\ a\ mouse\ button\ action,\ rather\ than\n\n======\nbind\ \$x\ <ButtonRelease-1>\ \ \{\ puts\ \"Unmodified\ button\"\ \}\nbind\ \$x\ <Shift-ButtonRelease-1>\ \{\ puts\ \"Shift\ button\ 1\ release\"\ \}\n======\n\n\n**\ Idea:\ <Invoke>\ event\ **\n\n\[Martin\ Lemburg\]\ 2002-07-02:\ Why\ isn't\ there\ an\ event\ ''Invoke''\ for\ invokeable\nwidgets,\ like\ buttons?\ Wouldn't\ make\ it\ sense\ to\ have\ such\ an\ event?\ To\ `bind`\nwidgets,\ like\ buttons?\ Wouldn't\ make\ it\ sense\ to\ have\ such\ an\ event?\ To\ bind\n''-command''\ option\ to\ an\ event\ handler?\n\nThan\ ...\n\n======\nbutton\ .b\ -text\ exit\ -command\ \{cmdProc\ .b\ \[clock\ seconds\]\}\;\n======\n\n...\ would\ be\ equal\ to\ ...\n\n======\nbind\ .b\ <Invoke>\ \{cmdProc\ %W\ %t\}\;\n======\n\nIt\ shouldn't\ be\ a\ problem\ to\ use\ the\ substitution\ capabilities\ during\ the\ usage\ of\ a\ binding,\ like:\n\n======\nbutton\ .b\ -text\ exit\ -command\ \{cmdProc\ %W\ %t\}\;\n======\n\nWouldn't\ that\ be\ nice\ and\ consequent?\n\nWouldn't\ it\ be\ consequent\ (for\ example)\ to\ use\ bindings\ to\ scrollbars\ or\nentries\ too?\ ...\n\n======\nentry\ \ \ \ \ .e\ \ \ -textvariable\ filter\;\nbutton\ \ \ \ .b\ \ \ -text\ \"filter\"\;\nlistbox\ \ \ .lb\ \ -listvar\ data\ -selectmode\ extended\;\nscrollbar\ .sbx\ -orient\ horizontal\;\nscrollbar\ .sby\ -orient\ vertical\;\n\nbind\ .e\ \ \ <Validate>\ \{validateFilter\ %V\ %s\}\;\nbind\ .b\ \ \ <Invoke>\ \ \ \{filter\ .e\ .lb\}\;\nbind\ .lb\ \ <XScroll>\ \ \{.sbx\ set\}\;\nbind\ .lb\ \ <YScroll>\ \ \{.sby\ set\}\;\nbind\ .sbx\ <Invoke>\ \ \ \{.lb\ xview\}\;\nbind\ .sby\ <Invoke>\ \ \ \{.lb\ yview\}\;\n======\n\nThere\ would\ be\ the\ chance\ to\ elimate\ all\ (event)handlers\ from\ that\ code,\ that\nonly\ builds\ up\ the\ GUI.\ The\ code\ to\ handle\ events\ could\ use\ now\ use\ bindings.\n\n\n\n**\ Caution:\ Abbreviated\ `bind`\ Descriptions\ **\n**\ Caution:\ Abbreviated\ \[\[`binc`\]\ Descriptions\ **\n\[Ken\ Jones\]\ writes\ on\ \[comp.lang.tcl\],\ in\ response\ to\ a\ developer\ trying\ to\n`bind`\ actions\ on\ numeric\ keys\ using\ \nbind\ actions\ on\ numeric\ keys\ using\ \n======\nbind\ .bu1\ <Alt-2>\ \{focus\ .bu2\}\nbind\ .bu1\ <Alt-2>\ \"focus\ .bu2\"\n\nWhat\ you're\ experiencing\ is\ one\ of\ those\ traps\ that\ people\ encounter\ when\ they\nuse\ abbreviated\ binding\ descriptions.\ For\ many\ `KeyPress`\ events,\ you\ can\ get\ by\nuse\ abbreviated\ binding\ descriptions.\ For\ many\ KeyPress\ events,\ you\ can\ get\ by\n<Control-a>\ is\ equivalent\ to\ <Control-KeyPress-a>.\n\nOn\ the\ other\ hand,\ Tcl\ also\ allows\ you\ to\ abbreviate\ ButtonPress\ events,\ so\ <1>\nis\ equivalent\ to\ <ButtonPress-1>.\ And\ <Alt-1>\ through\ <Alt-5>\ is\ equivalent\ to\n<Alt-ButtonPress-1>\ through\ <Alt-ButtonPress-5>.\n\nSolution?\ `bind`\ to\ `<Alt-KeyPress-1>`\ and\ `<Alt-KeyPress-2>`.\ And\ be\ very\ careful\nSolution?\ Bind\ to\ <Alt-KeyPress-1>\ and\ <Alt-KeyPress-2>.\ And\ be\ very\ careful\n\n\n\n**\ Keypad\ Keys\ **\n\n\[LV\]:\ I\ am\ trying\ to\ get\ the\ following\ sample\ program\ to\ display\ the\ numbers\n0-9\ when\ pressed\ on\ the\ keypad:\n\n======\n#!\ /usr/tcl84/bin/tclsh\n\npackage\ require\ Tk\n\nentry\ .e\nbind\ .e\ <KeyPress-1>\ \{\ puts\ 1\ \}\npack\ .e\nfocus\ .e\n======\n\nThe\ expectation\ was\ that\ I\ would\ get\ an\ entry\ widget\ into\ which\ I\ could\ press\nthe\ keys\ on\ the\ keypad\ and\ get,\ in\ this\ case,\ the\ number\ 1\ into\ the\ entry\nwidget.\ \ What\ I\ experience\ is\ that\ after\ I\ mouse\ into\ the\ widget\ and\ click,\ I\ncan\ type\ alphas\ and\ the\ numbers\ on\ top\ row\ of\ the\ main\ keyboard,\ but\ the\ keypad\nkeys\ are\ generating\ nothing...\n\nPeter\ Newman\ 2004-04-30:\ ''NumLock''\ switches\ the\ keypad\ between\ numbers\ and\ncursor\ keys.\ I\ presume\ you\ tried\ both\ settings\ -\ and\ still\ no\ joy.\ If\ so,\ then\nit\ would\ appear\ that\ Tk\ doesn't\ support\ the\ keyboard\ properly.\n\n\nPierre\ Coueffin\ 2004-04-12:\ Try\ `<KeyPress-KP_1>`\n\nThomas\ Guettler\ 26\ April\ 2006:\ Or\ Try\ `<KP_End>`\n\nYou\ can\ query\ the\ bindings\ interactively\ with\ this:\ (See\ above)\n\n======\nbind\ .\ <KeyPress>\ \{\ puts\ %K\ \}\ \;\ focus\ .\n======\n\n\n**\ Canonicalize\ a\ `bind`\ Specification\ **\n**\ Canonicalize\ a\ \[\[`bind`\]\ Specification\ **\nQ.\ Given\ a\ string\ specifying\ an\ event\ sequence,\ how\ to\ obtain\ some\ sort\ of\n\"normal\ form\"\ for\ that\ event\ sequence,\ so\ that,\ for\ example,\ `1`\ and\n`Mousebutton-1`\ (or\ whatever\ the\ long\ form\ is)\ both\ map\ to\ the\ same\ normal\ form\nindicating\ a\ single\ click\ of\ mouse\ button\ 1?\n\nA.\ \[KBK\]:\ Hmm,\ `bind`\ it\ to\ a\ nonexistent\ bindtag\ and\ then\ query\ the\ bindings\nA.\ (\[KBK\])\ Hmm,\ bind\ it\ to\ a\ nonexistent\ bindtag\ and\ then\ query\ the\ bindings\n\n======none\n%\ bind\ Nothing\ <Button1-ButtonPress-2>\ \{\;\}\n%\ bind\ Nothing\n<B1-Button-2>\n======\n\n\n**\ Control\ Sequences\ **\n\n\[Dossy\]\ 2005-03-29:\ I\ just\ spent\ a\ good\ hour\ only\ trying\ to\ understand\ `bind`\n\[Dossy\]\ 2005-03-29:\ I\ just\ spent\ a\ good\ hour\ only\ trying\ to\ understand\ \[\[`bind`\]\nonly\ to\ discover\ that\ \[\[`bind\ .\ <Control-a>\ \{script\}`\]\ is\ NOT\ the\ same\ as\ \[\[`bind\n.\ <Control-A>\ \{script\}`\].\ the\ former\ works,\ the\ latter\ doesn't.\n\[RS\]:\ would\ expect\ that\ `<Control-A>`\ is\ equivalent\ to\ `<Control-Shift-a>`\ ...\ case\n\[RS\]:\ would\ expect\ that\ <Control-A>\ is\ equivalent\ to\ <Control-Shift-a>\ ...\ case\n\n\[MG\]:\ The\ bindings\ for\ this,\ after\ a\ little\ playing,\ seem\ slightly\ strange.\nWithout\ Caps\ Lock\ on,\ Shift\ and\ the\ `a`\ (to\ get\ an\ upper-case\ A)\ fires\ the\nbinding\ for\ Shift\ and\ (uppercase)\ A.\ The\ only\ way\ to\ fire\ a\ binding\ for\ Shift\nand\ (lowercase)\ a\ that\ I\ can\ find\ is\ to\ turn\ Caps\ Lock\ on,\ and\ -then-\ press\ the\n'a'\ key\ with\ Shift\ held\ down.\n\nCJL\ The\ minimal\ example\ of\ this\ mildly\ unexpected\ behaviour\ is\ to\ switch\ Caps\nLock\ on,\ then\ in\ a\ Wish\ console\ (I'm\ talking\ Windoze\ here)\ type\ something,\nhighlight\ it\ and\ press\ Ctrl-C.\ Now\ try\ to\ paste\ your\ text\ somewhere\ else\ (e.g.\nNotepad)\ using\ Ctrl-V\ -\ you'll\ discover\ that\ the\ copy\ didn't\ happen,\ but\ even\nthough\ Caps\ Lock\ is\ still\ on,\ Notepad\ will\ quite\ happily\ obey\ the\ paste\ request\n(by\ pasting\ whatever\ was\ already\ in\ the\ clipboard).\ To\ me\ 'Ctrl-C'\ means\ \"the\nphysical\ key\ labelled\ with\ a\ 'C'\ was\ pressed\ while\ ctrl\ was\ down\",\ and\ should\nhave\ nothing\ to\ do\ with\ the\ state\ of\ Caps\ Lock,\ only\ the\ combination\ of\ keys\npressed.\n\n\[WHD\]:\ On\ both\ Windows\ and\ Mac\ OS\ X,\ normal\ apps\ accept\ both\ `<Control-v>`\ and\n\[WHD\]:\ On\ both\ Windows\ and\ Mac\ OS\ X,\ normal\ apps\ accept\ both\ Control-v\ and\nControl-V\ (Command-v\ and\ Command-V)\ as\ the\ Paste\ key.\ \ For\ Tk,\ it\ appears\ that\nall\ of\ the\ following\ combinations\ will\ paste:\n\n\ \ \ *\ `<Control-v>`\n\ \ \ *\ Control-v\n\ \ \ *\ Control-V\n\ \ \ *\ Shift-Control-v\n\ \ \ *\ Shift-Control-V\nIf\ you\ want\ to\ support\ Shift-Control\ sequences\ in\ your\ keyset,\ you\ need\ to\ bind\nboth\ `<Shift-Control-v>`\ and\ `<Shift-Control-V>`.\ \ Here's\ a\ simple\ solution\ that\nboth\ Shift-Control-v\ and\ Shift-Control-V.\ \ Here's\ a\ simple\ solution\ that\n\n======\nproc\ bindletterkey\ \{tag\ modifier\ letter\ binding\}\ \{\n\ \ \ \ set\ upper\ \[string\ toupper\ \$letter\]\n\ \ \ \ set\ lower\ \[string\ tolower\ \$letter\]\n\n\ \ \ \ bind\ \$tag\ <\$modifier-\$upper>\ \$binding\n\ \ \ \ bind\ \$tag\ <\$modifier-\$lower>\ \$binding\n\}\ \n\nbindletterkey\ .text\ Control\ F\ \ \ \ \ \ \ \{puts\ Control-F\}\nbindletterkey\ .text\ Control\ F\ \ \ \ \ \ \ \{puts\ \"Control-F\"\}\nbindletterkey\ .text\ Shift-Control\ F\ \{puts\ \"Shift-Control-F\"\}\n\n\n**\ Case\ Insensitive\ Binding\ **\n\n\[MG\]\ 2005-06-06:\ \ And,\ where\ the\ bindings\ already\ exist\ (ie,\ for\ the\ Text\nwidget)\ and\ you\ want\ to\ make\ them\ case-insensitive,\ something\ like\ this\ will\nhelp.\n\n======\nproc\ mirror\ \{class\ \{dir\ 1\}\}\ \{\n\ \ \ \ if\ \{\$dir\ eq\ \{1\}\}\ \{\n\ \ \ \ if\ \{\ \$dir\ ==\ \"1\"\ \}\ \{\n\ \ \ \ \ \ \ \ set\ range\ \"a-z\"\n\ \ \ \ \ \ \ \ set\ case\ \"toupper\"\n\ \ \ \ \ \ \ \ set\ range\ A-Z\n\ \ \ \ \ \ \ \ set\ range\ \"A-Z\"\n\ \ \ \ \ \ \ \ set\ case\ \"tolower\"\n\ \ \ \ foreach\ x\ \[bind\ \$class\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\[regexp\ \"^<(.+-)?\\\[\$range\]>\$\"\ \$x\]\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[regexp\ \"^<(.+-)?\[\$range\]>\$\"\ \$x\]\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ y\ \[string\ range\ \$x\ 0\ end-2\]\[string\ \$case\ \$y\]>\n\ \ \ \ \ \ \ \ \ \ \ \ set\ y\ \"\[string\ range\ \$x\ 0\ end-2\]\[string\ \$case\ \$y\]>\"\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\ \[bind\ \$class\ \$y\]\ !=\ \"\"\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ continue\;\n\ \ \ \ \ \ \ \ \ \ \ \ bind\ \$class\ \$y\ \[bind\ \$class\ \$x\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\;#\ mirror\n======\n\nThen\ run,\ for\ instance:\n\n======\nmirror\ Text\ 1\;\ \ #\ copy\ all\ lower-class\ bindings\ for\ the\ Text\ \ widget\ to\ upper-class\ versions\nmirror\ Text\ 0\;\ \ #\ copy\ all\ upper-class\ bindings\ for\ the\ Text\ \ widget\ to\ lower-class\ versions\nmirror\ Entry\ 1\;\ #\ copy\ all\ lower-class\ bindings\ for\ the\ Entry\ widget\ to\ upper-class\ versions\n======\n\nIt's\ also\ careful\ not\ to\ overwrite\ bindings\ -\ if\ you\ have\ an\ <a>\ and\ an\ <A>\nbinding\ for\ the\ Text\ widget,\ and\ run\ ''mirror\ Text\ 1'',\ <A>\ will\ be\ left\ as\ it\nis,\ rather\ than\ being\ overwritten\ with\ <a>'s\ binding.\n\nThis\ raises\ one\ question\ for\ me,\ though\ -\ what's\ better\ practice?\ Should\ you\nbind\ to\n\n======\nbind\ Text\ <A>\ \[bind\ Text\ <a>\]\n======\n\nand\ copy\ the\ binding,\ or\ use\ something\ like\n\n======\nbind\ Text\ <A>\ \{event\ generate\ %W\ <a>\}\n======\n\nto\ mirror\ <a>'s\ state\ at\ the\ time\ the\ event\ happens?\n\n\n**\ Unbound\ `bind`\ **\n**\ Unbound\ \[\[`bind`\]\ **\n\nSome\ of\ the\ best\ `bind`\ coding\ doesn't\ involve\ '''bind'''\ at\ all.\ \ \[DKF\],\nSome\ of\ the\ best\ \[\[`bind`\]\ coding\ doesn't\ involve\ '''bind'''\ at\ all.\ \ \[DKF\],\n\n======\nevent\ add\ <<Copy>>\ <Control-C>\n======\n\ntrumps\n\n======\nbind\ \$class\ <Control-Key-C>\ \[bind\ \$type\ <<Copy>>\]\nbind\ \$class\ <Control-Key-c>\ \[bind\ \$type\ <<Copy>>\]\n======\n\n\n...\ \ \[\[Correct\;\ elaborate\]\]\n\n\n\n**\ `bind`\ to\ a\ plain\ keystroke\ only\ (not\ modified\ by\ Ctrl\ or\ Alt)\ **\n**\ Bind\ to\ a\ plain\ keystroke\ only\ (not\ modified\ by\ Ctrl\ or\ Alt)\ **\n======\nproc\ bind'plainkey\ \{tag\ key\ script\}\ \{\ \n\ \ \ \ bind\ \$tag\ <Control-\$key>\ \{\}\ \n\ \ \ \ bind\ \$tag\ <Control-\$key>\ \{\ \}\ \n\ \ \ \ bind\ \$tag\ <Alt-\$key>\ \ \ \ \ \{\ \}\ \n\}\ \n======\n\nExample:\n\n======\nbind'plainkey\ all\ x\ \{puts\ Hello\}\ \n======\n\n----\n\n\[RUJ\]:\ If\ bind\ leave\ command\ to\ main\ window\ it\ is\ not\ (bindings)\ grabbing\ to\nits\ associated\ widgets.\ e.g.:\ \ \n\n======\ntoplevel\ \$wa\ -bd\ 1\ -relief\ ridge\ntoplevel\ \$wa\ -bd\ 1\ -relief\ ridge\ \;\nwm\ geometry\ \$wa\ 600x40+\$mousex+\$mousey\ \;\nwm\ resizable\ \$wa\ 0\ 0\ \;\nwm\ overrideredirect\ \$wa\ yes\ \;\nwm\ iconname\ \$wa\ \"menu\"\ \;\nwm\ group\ \$wa\ .\ \;\nfocus\ \$wa\ \;\ngrab\ set\ \$wa\ \;\nentry\ \$wa.ent01\ -width\ 6\ -background\ white\ \nentry\ \$wa.ent01\ \\\n\ \ \ \ \ \ \ -width\ 6\ -background\ white\ \nbind\ \$wa\ <1>\ \[list\ after\ cancel\ destroy\ .base\]\n\ \ \ \ \ \ \ \ bind\ \$wa\ <1>\ \[list\ after\ cancel\ destroy\ .base\]\n\ \ \ \ \ \ \ \ bind\ \$wa\ <Leave>\ \[list\ destroy\ .base\]\n======\n\nBut\ it\ is\ destroying\ base\ if\ cursor\ goes\ near\ to\ entry.\ \ Can\ anybody\ solve\ the\nproblem.\n\n\n**\ Disable\ Pasting\ **\n\n2008-03-17:\ How\ can\ I\ disable\ pasting\ into\ a\ text\ widget?\ I\ tried\ the\nfollowing:\n\n======\nbind\ \$theText\ <<Paste>>\ \{tk_messageBox\ -message\ \{Paste\ Attempt\}\}\nbind\ \$theText\ <<Paste>>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\nbind\ \$theText\ <Control-v>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\nbind\ \$theText\ <Button-2>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\nbind\ \$theText\ <Shift-Insert>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\n\nThe\ message\ boxes\ are\ shown,\ so\ the\ event\ handling\ works.\ But\ after\ the\ message\nbox\ has\ been\ clicked\ away,\ the\ pasting\ takes\ place\ anyway\ -\ at\ least\ for\nShift-Insert.\n\nAnswer:\ You\ are\ adding\ bindings\ to\ the\ widget\ but\ aren't\ addressing\ the\nbindings\ associated\ with\ the\ widget\ class.\ Read\ up\ on\ `\[bindtags\]`.\ One\ solution\nbindings\ associated\ with\ the\ widget\ class.\ Read\ up\ on\ \[bindtags\].\ One\ solution\nis\ to\ add\ \"\;break\"\ to\ each\ binding\ to\ prevent\ the\ class\ bindings\ from\ firing:\n======\nbind\ \$theText\ <<Paste>>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\;\ break\}\n======\n\ \ \nOf\ course,\ you\ can\ also\ just\ set\ the\ -state\ option\ to\ \"disabled\".\n\n\n\n***\ Class\ binding,\ do\ they\ work?\ ***\n\n\[Janic\]:\ 2009-07-01T09:48:17:\n\nI\ tried\ to\ set\ a\ class\ binding\ but\ it\ never\ works.\ For\ example:\n\n======\ncheckbutton\ .a\ -text\ test\npack\ .a\nbind\ .a\ <ButtonPress>\ break\nbind\ .a\ <ButtonPress>\ \"break\"\n\nworks\ fine\ (the\ widget\ is\ still\ active\ but\ you\ can't\ check\ it\ anymore),\ but\ if\nwrite\n\n======\nbind\ Checkbutton\ <ButtonPress>\ break\nbind\ Checkbutton\ <ButtonPress>\ \"break\"\n\nit\ doesn't\ work.\ \ Did\ I\ miss\ something\ in\ the\ class\ binding\ behavior?\n\n\[MG\]:\ Many\ different\ bindings\ are\ checked\ for\ a\ widget,\ based\ on\ its\n\[bindtags\].\ \ The\ default\ order\ for\ a\ widget\ is:\ bindings\ on\ the\ widget\ itself,\nbindings\ on\ its\ class,\ its\ toplevel,\ and\ then\ on\ `all`.\ Also,\ bindings\ are\nbindings\ on\ its\ class,\ its\ toplevel,\ and\ then\ on\ \"all\".\ Also,\ bindings\ are\nkey,\ it\ checks\ for\ KeyPress-a\ before\ a\ more\ generic\ KeyPress,\ etc).\n\nThat's\ why\ you're\ seeing\ what\ you\ see\;\ first\ the\ widget's\ own\ bindings\ are\nchecked,\ and\ the\ generic\ `<ButtonPress>`\ binding\ matches\ and\ is\ run\;\ `\[break\]`\nchecked,\ and\ the\ generic\ <ButtonPress>\ binding\ matches\ and\ is\ run\;\ the\ \[break\]\n\nWhen\ you\ `bind`\ that\ on\ the\ Checkbutton\ class,\ though,\ the\ default\nWhen\ you\ bind\ that\ on\ the\ Checkbutton\ class,\ though,\ the\ default\n<ButtonPress-1>\ binding\ is\ more\ specific,\ and\ gets\ used\ instead\ of\ your\n<ButtonPress>\ binding.\ (You\ can\ see\ all\ the\ default\ bindings\ with\ \[\[bind\nCheckbutton\]\],\ then\ see\ what\ a\ specific\ one\ does\ with\ \[\[bind\ Checkbutton\n\$binding\]\].)\ So,\ to\ override\ the\ default\ binding,\ you'd\ need\ to\ either\ replace\nthe\ Button-1\ binding,\ or\ add\ something\ higher\ up\ the\ \[bindtags\]\ chain.\n\[DKF\]:\ You\ are\ advised\ to\ be\ ''very''\ careful\ with\ changing\ bindings\ of\ widget\nclasses,\ as\ that\ affects\ ''all''\ widgets\ of\ that\ type\ in\ the\ application.\ (It's\nmost\ useful\ if\ you're\ adding\ more\ editing\ keys\ to\ the\ `\[text\]`\ \[widget\],\ or\ are\nmost\ useful\ if\ you're\ adding\ more\ editing\ keys\ to\ the\ \[text\]\ \[widget\],\ or\ are\nmaking\ your\ own\ megawidget\ class.)\ It's\ far\ better\ to\ adjust\ the\ \[bindtags\]\ for\n\n\[wdb\]:\ Here\ an\ example:\ button\ `.b`\ has\ new\ binding\ tag,\ \ `Button1`\ instead\ of\n`Button`.\ \ Bindings\ are\ copied\ from\ `Button`\ to\ `lButton1`,\ then\ binding\ of\n`<1>`\ is\ modified:\n\n===\n%\ package\ require\ Tk\n8.5.1\n%\ pack\ \[button\ .b\ -text\ Howdy\]\n%\ #\ button\ appears\n%\ bindtags\ .b\n.b\ Button\ .\ all\n%\ bindtags\ .b\ \{.b\ Button1\ .\ all\}\n%\ bindtags\ .b\ \".b\ Button1\ .\ all\"\n\ \ foreach\ p\ \[bind\ \$old\]\ \{\n\ \ \ \ \ \ bind\ \$new\ \$p\ \[bind\ \$old\ \$p\]\n\ \ \ \ \}\n\}\}\ Button\ Button1\n%\n%\ bind\ Button1\ <1>\ \"+puts\ yep!\"\n%\ #\ now\ clicking\ on\ .b:\n%\ yep!\n\n%\ \n===\n\nFrom\ now\ on,\ you\ can\ change\ arbitrary\ buttons\ without\ side-effects\ to\ \"normal\"\nbuttons.\n\n\n----\n**\n'''\[telgo\]\ -\ 2010-07-29\ 15:22:47'''\n\[telgo\]\ 2010-07-29\ 15:22:47:\n\n======\nbind\ .\ <Command-f>\ \{\nbind\ .\ <Command-f>\ \{Find\;break\}\n\nI\ also\ have\ a\ menu\ item\ that\ calls\ Find\n\n======\n\$Test\ add\ command\ -label\ Find\ -accel\ Command-F\ -command\ Find\n======\n\n`Find`\ puts\ up\ a\ dialox\ box,\ but\ involves\ some\ sorting.\ However,\ it\nThe\ Find\ procedure\ puts\ up\ a\ dialox\ box,\ but\ involves\ some\ sorting.\ However,\ it\n\n======\nproc\ Find\ \{\}\ \{\n\ \ \ \ global\ body\ dict\ t\n\ \ \ \ \n\ \ \ \ set\ t1\ \[clock\ clicks\ -milliseconds\]\ \ \ \ \ \ \ \ \n\ \ \ \ set\ f\ .dictdisplay\n\ \ \ \ \n\ \ \ \ #see\ if\ we\ want\ to\ restrict\ display\n\ \ \ \ set\ target\ \{\}\n\ \ \ \ if\ \{\[\$t\ tag\ ranges\ sel\]\ ne\ \{\}\}\ \{\n\ \ \ \ if\ \{\ \[\$t\ tag\ ranges\ sel\]\ ne\ \"\"\ \}\ \{\n\ \ \ \ \ \ \ \ set\ target\ \[::soundex::soundex\ \$term\]\n\ \ \ \ \}\ \n\ \ \ \ \n\ \ \ \ if\ \[Dialog_Create\ \$f\ Dictionary\ -borderwidth\ 10\]\ \{\n\ \ \ \ if\ \[Dialog_Create\ \$f\ \"Dictionary\"\ -borderwidth\ 10\]\ \{\n\ \ \ \ \ \ \ \ set\ b\ \[frame\ \$f.buttons\]\n\n\ \ \ \ \ \ \ \ #---------\ convert\ the\ array\ to\ a\ list\n\ \ \ \ \ \ \ \ foreach\ index\ \[array\ names\ dict\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ sort\ \$index\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ sort\ \"\$index\"\n\ \ \ \ \ \ \ \ set\ sorted\ \[WolofSort\ \$sort\]\n\ \ \ \ \ \ \ \ foreach\ item\ \$sorted\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$target\ eq\ \{\}\ ||\ \$target\ eq\ \[::soundex::soundex\ \$item\]\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$text\ insert\ end\ \"\$item\ :\ \$dict(\$item)\\n\"\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ pack\ \$f.body\ \ \$f.buttons\ -side\ top\ -fill\ x\n\ \ \ \ \ \ \ \ button\ \$b.ok\ -text\ OK\ -command\ \{set\ dictdisplay(ok)\ 1\}\n\ \ \ \ \ \ \ \ pack\ \$b.ok\ -side\ right\n\ \ \ \ \}\n\ \ \ \ set\ t2\ \[clock\ clicks\ -milliseconds\]\n\ \ \ \ puts\ \"\[expr\ \{(\$t2-\$t1)/1000.0\}\]\ seconds\"\n\ \ \ \ puts\ \"\[expr\ (\$t2-\$t1)/1000.0\]\ seconds\"\n\ \ \ \ set\ dictdisplay(ok)\ 0\n\ \ \ \ Dialog_Wait\ \$f\ dictdisplay(ok)\ \n\ \ \ \ \n\ \ \ \ set\ t3\ \[clock\ clicks\ -milliseconds\]\n\ \ \ \ puts\ \"\[expr\ \{(\$t3-\$t2)/1000\}\]\ seconds\"\n\ \ \ \ puts\ \"\[expr\ (\$t3-\$t2)/1000\]\ seconds\"\n\}\n======\n\nIf\ I\ use\ the\ menu\ item,\ everything\ works\ as\ expected.\ If\ I\ use\ Command-f,\ there\nis\ a\ noticeable\ pause,\ then\ the\ dialog\ appears\ -\ undecorated\ -\ with\ the\ data\ in\nit\ and\ the\ ok\ button,\ but\ never\ returns\ from\ Dialog_Create.\ `Dialog_Create`,\nit\ and\ the\ ok\ button,\ but\ never\ returns\ from\ Dialog_Create.\ \[Dialog_Create,\nDialog_Wait\ and\ Dialog_Dismiss\ are\ taken\ from\ Welch,\ Jones\ and\ Hobbs\ 2003\n\nIs\ there\ an\ issue\ with\ putting\ up\ a\ dialog\ box\ from\ within\ a\ key-binding?\n\n<<discussion>> regexp2} CALL {my render bind \['''`\[http://www.tcl.tk/man/tcl/TkCmd/bind.htm%|%bind\]`'''\],\ a\ \[Tk\n\[script%|%scripts\].\n\[scripts\].\n\n\n**\ Documentation\ **\n*\ See\ Also\ **\n\n\ \ \ \[Bindings\ and\ why\ they\ are\ important\]:\ \ \ \n\n\ \ \ \[Bindings\ and\ variable\ substitution\]:\ \ \ \n\n\ \ \ \[Disable\ autorepeat\ under\ X11\]:\ \ \ \n\n\ \ \ \[mousewheel\]\ bindings:\ \ \ \n\n\ \ \ \[binding\ to\ a\ single\ mouse\ click\]:\ \ \ \n\n\ \ \ \[Key-press\ names\]:\ \ \ \n\n\ \ \ \[Portable\ keystate\]:\ \ \ \n\n\n\n\n\ \ \ \[http://www.tcl.tk/man/tcl/TkCmd/bind.htm%|%official\ reference\]:\ \ \ \n\n\ \ \ `\[keysyms\]`:\ \ \ the\ keyboard\ symbols\ to\ which\ one\ can\ potentially\ bind\ things.\ \ Of\ course,\ the\ specific\ keysyms\ available\ to\ you\ on\ any\ particular\ platform/hardware\ depend\ on\ factors\ outside\ of\ Tk's\ control.\ \ (See\ below\ for\ a\ simple\ script\ for\ determining\ what\ the\ specific\ keysym\ for\ a\ character\ is.)\n\ \ \ \[keysyms\]:\ \ \ the\ keyboard\ symbols\ to\ which\ one\ can\ potentially\ bind\ things.\ \ Of\ course,\ the\ specific\ keysyms\ available\ to\ you\ on\ any\ particular\ platform/hardware\ depend\ on\ factors\ outside\ of\ Tk's\ control.\ \ (See\ below\ for\ a\ simple\ script\ for\ determining\ what\ the\ specific\ keysym\ for\ a\ character\ is.)\n\n\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag''\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag\ sequence''\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag\ sequence\ script''\n\n\ \ \ \ :\ \ \ '''bind'''\ ''tag\ sequence\ '''''+'''''script''\n\n\n\n**\ Description\ **\n\n`bind`\ (part\ of\ \[Tk\])\ is\ used\ to\ associate\ Tcl\ commands\ to\ execute\ upon\nthe\ press\ of\ specific\ keys.\ \ Also,\ `bind`\ may\ be\ driven\ by\ other\ events,\ both\nthe\ press\ of\ specific\ keys.\ \ Also,\ bind\ may\ be\ driven\ by\ other\ events,\ both\ndocumentation\ for\ specific\ details.\n\n''tag''\ is\ formally\ a\ `\[bindtags\]`\ tag,\ but\ for\ most\ user\ code\ it\ is\ best\ to\n''tag''\ is\ formally\ a\ \[bindtags\]\ tag,\ but\ for\ most\ user\ code\ it\ is\ best\ to\nomitted,\ `bind`\ returns\ what\ bindings\ are\ set\ on\ ''tag''.\ If\ ''script''\ is\nomitted,\ '''bind'''\ returns\ what\ bindings\ are\ set\ on\ ''tag''.\ If\ ''script''\ is\n“'''+'''”)\ the\ binding\ script,\ and\ if\ ''script''\ is\ omitted\ (but\ ''sequence''\nis\ given)\ then\ the\ current\ binding\ script\ is\ returned.\n\nKeyboard\ symbols\ are\ the\ Tk\ values\ associated\ with\ particular\ sequences\ of\nkeyboard\ keys\ that\ one\ can\ press,\ such\ as\ Shift,\ or\ A\ or\ special\ function\ keys\nsuch\ as\ Page\ Up,\ etc.\n\n\n\n**\ Examples\ **\n\n\ \ \ \[Only\ in\ tcl...\]:\ \ \ A\ nice\ simple\ example\ of\ `bind`\ in\ action\n\ \ \ \[Vogel\ spiral\]:\ \ \ uses\ \[\[`\[apply\]`\]\ as\ the\ script\ for\ \[\[`\[bind\]`\]\n\ \ \ \[Salvatore\ Sanfilippo\]:\ \ \ has\ an\ example\ on\ his\ page\ of\ using\ a\ keyboard\ n\ \"raw\"\ mode\n\n\nIf\ you\ are\ looking\ for\ the\ \[eggdrop\]\ `bind`\ command,\ try\ \[http://www.eggheads.org/support/egghtml/1.6.17/tcl-commands.html#bind%|%bind%|%\]\nIf\ you\ are\ looking\ for\ the\ \[eggdrop\]\ bind\ command,\ try\ \[http://www.eggheads.org/support/egghtml/1.6.17/tcl-commands.html#bind%|%bind%|%\]\n\n<<discussion>>\n**\ Discussion\ **\n\n\n**\ Unanswered\ Questions\ **\n\n\n'''Question''':\ Is\ there\ an\ introspective\ method\ that\ a\ Tk\ application\ can\ndetermine\ whether\ a\ keysym\ is\ currently\ available\ for\ it\ to\ use?\n\n\n\n**\ Answered\ Questions\ **\n\n\ \ \ *\ \[Moving\ Canvas\ Window\ Items\ -\ Can\ someone\ tell\ me\ what's\ going\ on\ here?\]\n\n\n**\ `bind`\ Syntax\ Example\ **\n**\ \[\[`bind`\]\ Syntax\ Example\ **\n\[RS\]\ writes\ on\ comp.lang.tcl:\ The\ `bind`\ syntax\ is\ actually\ very\ easy.\ With\ x\ set\n\[RS\]\ writes\ on\ comp.lang.tcl:\ The\ bind\ syntax\ is\ actually\ very\ easy.\ With\ x\ set\n\n======\nbind\ \$x\n======\n\nto\ get\ a\ list\ of\ defined\ bindings.\ This\ list\ contains\ <Key-Prior>\ which\ is\ the\ncorrect\ name\ for\ the\ Page\ Up\ key.\ To\ see\ what\ it\ is\ bound\ to,\ call\n\n======\nbind\ \$x\ <Key-Prior>\n======\n\nTo\ mirror\ this\ binding\ to\ another\ event,\ make\ that\n\n======\nbind\ \$x\ <Control-r>\ \[bind\ \$x\ <Key-Prior>\]\n======\n\nlike\ you\ tried,\ just\ with\ the\ incorrect\ name.\ BTW,\ you\ normally\ need\ not\ninclude\ variable\ names\ in\ braces\ -\ only\ if\ they\ contain\ characters\ other\ than\n`A-Z\ a-z\ 0-9\ _`.\n\n\n\n**\ Finding\ keysyms\ ***\n\n\[KBK\]:\ You\ can\ find\ the\ keysym\ for\ a\ key\ on\ an\ unfamiliar\ keyboard\ by\ running\n\[KBK\]\ -\ You\ can\ find\ the\ keysym\ for\ a\ key\ on\ an\ unfamiliar\ keyboard\ by\ running\n\n======\nbind\ .\ <KeyPress>\ \{puts\ %K\}\ \;\ focus\ .\n======\n\ndirecting\ focus\ at\ the\ (empty)\ ''wish''\ window,\ and\ touching\ the\ key\ in\nquestion.\ \ On\ Windows,\ you'll\ need\ to\ add\n\n======\nconsole\ show\n======\n\nto\ the\ script\ so\ that\ you\ can\ see\ its\ output.\n\n\[Arjen\ Markus\]:\ You\ may\ also\ put\ up\ a\ text\ widget\ and\ display\ the\ keysym\ by\ the\nfollowing\ script:\n\n======\nbind\ .textwidget\ <KeyPress>\ \{\ %W\ insert\ end\ \"%K\\n\"\ \}\nfocus\ .textwidget\n======\n\n\n**\ Specifying\ a\ Key\ to\ `bind`\ **\n**\ Specifying\ a\ Key\ to\ Bind\ **\n\[Arjen\ Markus\]:\ There\ are\ several\ ways\ to\ define\ a\ specific\ key,\ for\ instance:\n\[Arjen\ Markus\]\ There\ are\ several\ ways\ to\ define\ a\ specific\ key,\ for\ instance:\n======\n<Key-keysym>\n<KeyPress-keysym>\n<KeyRelease-keysym>\ (subtle\ differences\ here!)\n<keysym>\n<A>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (if\ the\ character\ is\ plain\ ASCII)\n======\n\nFor\ a\ space,\ you\ will\ need\ to\ use:\n\n======\n<Key-space>\n======\n\nanything\ else\ seems\ to\ give\ problems.\n\nAlso\ note\ that\ keysyms\ are\ case-sensitive:\ \"Down\"\ for\ the\ downward\ arrow\ and\n\"space\"\ for\ a\ space\ (\"down\"\ and\ \"Space\"\ do\ ''not''\ work\;\ quotation\ marks\ for\nconvenience\ only)\n\n\n\n**\ `bind`\ to\ a\ Mouse\ Action\ **\n**\ \[\[`bind`\]\ to\ a\ Mouse\ Action\ **\n\[LV\]:\ If\ you\ are\ wanting\ to\ `bind`\ actions\ to\ a\ mouse\ button\ action,\ rather\ than\n\[LV\]:\ If\ you\ are\ wanting\ to\ bind\ actions\ to\ a\ mouse\ button\ action,\ rather\ than\n\n======\nbind\ \$x\ <ButtonRelease-1>\ \ \{\ puts\ \"Unmodified\ button\"\ \}\nbind\ \$x\ <Shift-ButtonRelease-1>\ \{\ puts\ \"Shift\ button\ 1\ release\"\ \}\n======\n\n\n**\ Idea:\ <Invoke>\ event\ **\n\n\[Martin\ Lemburg\]\ 2002-07-02:\ Why\ isn't\ there\ an\ event\ ''Invoke''\ for\ invokeable\nwidgets,\ like\ buttons?\ Wouldn't\ make\ it\ sense\ to\ have\ such\ an\ event?\ To\ `bind`\nwidgets,\ like\ buttons?\ Wouldn't\ make\ it\ sense\ to\ have\ such\ an\ event?\ To\ bind\n''-command''\ option\ to\ an\ event\ handler?\n\nThan\ ...\n\n======\nbutton\ .b\ -text\ exit\ -command\ \{cmdProc\ .b\ \[clock\ seconds\]\}\;\n======\n\n...\ would\ be\ equal\ to\ ...\n\n======\nbind\ .b\ <Invoke>\ \{cmdProc\ %W\ %t\}\;\n======\n\nIt\ shouldn't\ be\ a\ problem\ to\ use\ the\ substitution\ capabilities\ during\ the\ usage\ of\ a\ binding,\ like:\n\n======\nbutton\ .b\ -text\ exit\ -command\ \{cmdProc\ %W\ %t\}\;\n======\n\nWouldn't\ that\ be\ nice\ and\ consequent?\n\nWouldn't\ it\ be\ consequent\ (for\ example)\ to\ use\ bindings\ to\ scrollbars\ or\nentries\ too?\ ...\n\n======\nentry\ \ \ \ \ .e\ \ \ -textvariable\ filter\;\nbutton\ \ \ \ .b\ \ \ -text\ \"filter\"\;\nlistbox\ \ \ .lb\ \ -listvar\ data\ -selectmode\ extended\;\nscrollbar\ .sbx\ -orient\ horizontal\;\nscrollbar\ .sby\ -orient\ vertical\;\n\nbind\ .e\ \ \ <Validate>\ \{validateFilter\ %V\ %s\}\;\nbind\ .b\ \ \ <Invoke>\ \ \ \{filter\ .e\ .lb\}\;\nbind\ .lb\ \ <XScroll>\ \ \{.sbx\ set\}\;\nbind\ .lb\ \ <YScroll>\ \ \{.sby\ set\}\;\nbind\ .sbx\ <Invoke>\ \ \ \{.lb\ xview\}\;\nbind\ .sby\ <Invoke>\ \ \ \{.lb\ yview\}\;\n======\n\nThere\ would\ be\ the\ chance\ to\ elimate\ all\ (event)handlers\ from\ that\ code,\ that\nonly\ builds\ up\ the\ GUI.\ The\ code\ to\ handle\ events\ could\ use\ now\ use\ bindings.\n\n\n\n**\ Caution:\ Abbreviated\ `bind`\ Descriptions\ **\n**\ Caution:\ Abbreviated\ \[\[`binc`\]\ Descriptions\ **\n\[Ken\ Jones\]\ writes\ on\ \[comp.lang.tcl\],\ in\ response\ to\ a\ developer\ trying\ to\n`bind`\ actions\ on\ numeric\ keys\ using\ \nbind\ actions\ on\ numeric\ keys\ using\ \n======\nbind\ .bu1\ <Alt-2>\ \{focus\ .bu2\}\nbind\ .bu1\ <Alt-2>\ \"focus\ .bu2\"\n\nWhat\ you're\ experiencing\ is\ one\ of\ those\ traps\ that\ people\ encounter\ when\ they\nuse\ abbreviated\ binding\ descriptions.\ For\ many\ `KeyPress`\ events,\ you\ can\ get\ by\nuse\ abbreviated\ binding\ descriptions.\ For\ many\ KeyPress\ events,\ you\ can\ get\ by\n<Control-a>\ is\ equivalent\ to\ <Control-KeyPress-a>.\n\nOn\ the\ other\ hand,\ Tcl\ also\ allows\ you\ to\ abbreviate\ ButtonPress\ events,\ so\ <1>\nis\ equivalent\ to\ <ButtonPress-1>.\ And\ <Alt-1>\ through\ <Alt-5>\ is\ equivalent\ to\n<Alt-ButtonPress-1>\ through\ <Alt-ButtonPress-5>.\n\nSolution?\ `bind`\ to\ `<Alt-KeyPress-1>`\ and\ `<Alt-KeyPress-2>`.\ And\ be\ very\ careful\nSolution?\ Bind\ to\ <Alt-KeyPress-1>\ and\ <Alt-KeyPress-2>.\ And\ be\ very\ careful\n\n\n\n**\ Keypad\ Keys\ **\n\n\[LV\]:\ I\ am\ trying\ to\ get\ the\ following\ sample\ program\ to\ display\ the\ numbers\n0-9\ when\ pressed\ on\ the\ keypad:\n\n======\n#!\ /usr/tcl84/bin/tclsh\n\npackage\ require\ Tk\n\nentry\ .e\nbind\ .e\ <KeyPress-1>\ \{\ puts\ 1\ \}\npack\ .e\nfocus\ .e\n======\n\nThe\ expectation\ was\ that\ I\ would\ get\ an\ entry\ widget\ into\ which\ I\ could\ press\nthe\ keys\ on\ the\ keypad\ and\ get,\ in\ this\ case,\ the\ number\ 1\ into\ the\ entry\nwidget.\ \ What\ I\ experience\ is\ that\ after\ I\ mouse\ into\ the\ widget\ and\ click,\ I\ncan\ type\ alphas\ and\ the\ numbers\ on\ top\ row\ of\ the\ main\ keyboard,\ but\ the\ keypad\nkeys\ are\ generating\ nothing...\n\nPeter\ Newman\ 2004-04-30:\ ''NumLock''\ switches\ the\ keypad\ between\ numbers\ and\ncursor\ keys.\ I\ presume\ you\ tried\ both\ settings\ -\ and\ still\ no\ joy.\ If\ so,\ then\nit\ would\ appear\ that\ Tk\ doesn't\ support\ the\ keyboard\ properly.\n\n\nPierre\ Coueffin\ 2004-04-12:\ Try\ `<KeyPress-KP_1>`\n\nThomas\ Guettler\ 26\ April\ 2006:\ Or\ Try\ `<KP_End>`\n\nYou\ can\ query\ the\ bindings\ interactively\ with\ this:\ (See\ above)\n\n======\nbind\ .\ <KeyPress>\ \{\ puts\ %K\ \}\ \;\ focus\ .\n======\n\n\n**\ Canonicalize\ a\ `bind`\ Specification\ **\n**\ Canonicalize\ a\ \[\[`bind`\]\ Specification\ **\nQ.\ Given\ a\ string\ specifying\ an\ event\ sequence,\ how\ to\ obtain\ some\ sort\ of\n\"normal\ form\"\ for\ that\ event\ sequence,\ so\ that,\ for\ example,\ `1`\ and\n`Mousebutton-1`\ (or\ whatever\ the\ long\ form\ is)\ both\ map\ to\ the\ same\ normal\ form\nindicating\ a\ single\ click\ of\ mouse\ button\ 1?\n\nA.\ \[KBK\]:\ Hmm,\ `bind`\ it\ to\ a\ nonexistent\ bindtag\ and\ then\ query\ the\ bindings\nA.\ (\[KBK\])\ Hmm,\ bind\ it\ to\ a\ nonexistent\ bindtag\ and\ then\ query\ the\ bindings\n\n======none\n%\ bind\ Nothing\ <Button1-ButtonPress-2>\ \{\;\}\n%\ bind\ Nothing\n<B1-Button-2>\n======\n\n\n**\ Control\ Sequences\ **\n\n\[Dossy\]\ 2005-03-29:\ I\ just\ spent\ a\ good\ hour\ only\ trying\ to\ understand\ `bind`\n\[Dossy\]\ 2005-03-29:\ I\ just\ spent\ a\ good\ hour\ only\ trying\ to\ understand\ \[\[`bind`\]\nonly\ to\ discover\ that\ \[\[`bind\ .\ <Control-a>\ \{script\}`\]\ is\ NOT\ the\ same\ as\ \[\[`bind\n.\ <Control-A>\ \{script\}`\].\ the\ former\ works,\ the\ latter\ doesn't.\n\[RS\]:\ would\ expect\ that\ `<Control-A>`\ is\ equivalent\ to\ `<Control-Shift-a>`\ ...\ case\n\[RS\]:\ would\ expect\ that\ <Control-A>\ is\ equivalent\ to\ <Control-Shift-a>\ ...\ case\n\n\[MG\]:\ The\ bindings\ for\ this,\ after\ a\ little\ playing,\ seem\ slightly\ strange.\nWithout\ Caps\ Lock\ on,\ Shift\ and\ the\ `a`\ (to\ get\ an\ upper-case\ A)\ fires\ the\nbinding\ for\ Shift\ and\ (uppercase)\ A.\ The\ only\ way\ to\ fire\ a\ binding\ for\ Shift\nand\ (lowercase)\ a\ that\ I\ can\ find\ is\ to\ turn\ Caps\ Lock\ on,\ and\ -then-\ press\ the\n'a'\ key\ with\ Shift\ held\ down.\n\nCJL\ The\ minimal\ example\ of\ this\ mildly\ unexpected\ behaviour\ is\ to\ switch\ Caps\nLock\ on,\ then\ in\ a\ Wish\ console\ (I'm\ talking\ Windoze\ here)\ type\ something,\nhighlight\ it\ and\ press\ Ctrl-C.\ Now\ try\ to\ paste\ your\ text\ somewhere\ else\ (e.g.\nNotepad)\ using\ Ctrl-V\ -\ you'll\ discover\ that\ the\ copy\ didn't\ happen,\ but\ even\nthough\ Caps\ Lock\ is\ still\ on,\ Notepad\ will\ quite\ happily\ obey\ the\ paste\ request\n(by\ pasting\ whatever\ was\ already\ in\ the\ clipboard).\ To\ me\ 'Ctrl-C'\ means\ \"the\nphysical\ key\ labelled\ with\ a\ 'C'\ was\ pressed\ while\ ctrl\ was\ down\",\ and\ should\nhave\ nothing\ to\ do\ with\ the\ state\ of\ Caps\ Lock,\ only\ the\ combination\ of\ keys\npressed.\n\n\[WHD\]:\ On\ both\ Windows\ and\ Mac\ OS\ X,\ normal\ apps\ accept\ both\ `<Control-v>`\ and\n\[WHD\]:\ On\ both\ Windows\ and\ Mac\ OS\ X,\ normal\ apps\ accept\ both\ Control-v\ and\nControl-V\ (Command-v\ and\ Command-V)\ as\ the\ Paste\ key.\ \ For\ Tk,\ it\ appears\ that\nall\ of\ the\ following\ combinations\ will\ paste:\n\n\ \ \ *\ `<Control-v>`\n\ \ \ *\ Control-v\n\ \ \ *\ Control-V\n\ \ \ *\ Shift-Control-v\n\ \ \ *\ Shift-Control-V\nIf\ you\ want\ to\ support\ Shift-Control\ sequences\ in\ your\ keyset,\ you\ need\ to\ bind\nboth\ `<Shift-Control-v>`\ and\ `<Shift-Control-V>`.\ \ Here's\ a\ simple\ solution\ that\nboth\ Shift-Control-v\ and\ Shift-Control-V.\ \ Here's\ a\ simple\ solution\ that\n\n======\nproc\ bindletterkey\ \{tag\ modifier\ letter\ binding\}\ \{\n\ \ \ \ set\ upper\ \[string\ toupper\ \$letter\]\n\ \ \ \ set\ lower\ \[string\ tolower\ \$letter\]\n\n\ \ \ \ bind\ \$tag\ <\$modifier-\$upper>\ \$binding\n\ \ \ \ bind\ \$tag\ <\$modifier-\$lower>\ \$binding\n\}\ \n\nbindletterkey\ .text\ Control\ F\ \ \ \ \ \ \ \{puts\ Control-F\}\nbindletterkey\ .text\ Control\ F\ \ \ \ \ \ \ \{puts\ \"Control-F\"\}\nbindletterkey\ .text\ Shift-Control\ F\ \{puts\ \"Shift-Control-F\"\}\n\n\n**\ Case\ Insensitive\ Binding\ **\n\n\[MG\]\ 2005-06-06:\ \ And,\ where\ the\ bindings\ already\ exist\ (ie,\ for\ the\ Text\nwidget)\ and\ you\ want\ to\ make\ them\ case-insensitive,\ something\ like\ this\ will\nhelp.\n\n======\nproc\ mirror\ \{class\ \{dir\ 1\}\}\ \{\n\ \ \ \ if\ \{\$dir\ eq\ \{1\}\}\ \{\n\ \ \ \ if\ \{\ \$dir\ ==\ \"1\"\ \}\ \{\n\ \ \ \ \ \ \ \ set\ range\ \"a-z\"\n\ \ \ \ \ \ \ \ set\ case\ \"toupper\"\n\ \ \ \ \ \ \ \ set\ range\ A-Z\n\ \ \ \ \ \ \ \ set\ range\ \"A-Z\"\n\ \ \ \ \ \ \ \ set\ case\ \"tolower\"\n\ \ \ \ foreach\ x\ \[bind\ \$class\]\ \{\n\ \ \ \ \ \ \ \ if\ \{\[regexp\ \"^<(.+-)?\\\[\$range\]>\$\"\ \$x\]\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[regexp\ \"^<(.+-)?\[\$range\]>\$\"\ \$x\]\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ y\ \[string\ range\ \$x\ 0\ end-2\]\[string\ \$case\ \$y\]>\n\ \ \ \ \ \ \ \ \ \ \ \ set\ y\ \"\[string\ range\ \$x\ 0\ end-2\]\[string\ \$case\ \$y\]>\"\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\ \[bind\ \$class\ \$y\]\ !=\ \"\"\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ continue\;\n\ \ \ \ \ \ \ \ \ \ \ \ bind\ \$class\ \$y\ \[bind\ \$class\ \$x\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\;#\ mirror\n======\n\nThen\ run,\ for\ instance:\n\n======\nmirror\ Text\ 1\;\ \ #\ copy\ all\ lower-class\ bindings\ for\ the\ Text\ \ widget\ to\ upper-class\ versions\nmirror\ Text\ 0\;\ \ #\ copy\ all\ upper-class\ bindings\ for\ the\ Text\ \ widget\ to\ lower-class\ versions\nmirror\ Entry\ 1\;\ #\ copy\ all\ lower-class\ bindings\ for\ the\ Entry\ widget\ to\ upper-class\ versions\n======\n\nIt's\ also\ careful\ not\ to\ overwrite\ bindings\ -\ if\ you\ have\ an\ <a>\ and\ an\ <A>\nbinding\ for\ the\ Text\ widget,\ and\ run\ ''mirror\ Text\ 1'',\ <A>\ will\ be\ left\ as\ it\nis,\ rather\ than\ being\ overwritten\ with\ <a>'s\ binding.\n\nThis\ raises\ one\ question\ for\ me,\ though\ -\ what's\ better\ practice?\ Should\ you\nbind\ to\n\n======\nbind\ Text\ <A>\ \[bind\ Text\ <a>\]\n======\n\nand\ copy\ the\ binding,\ or\ use\ something\ like\n\n======\nbind\ Text\ <A>\ \{event\ generate\ %W\ <a>\}\n======\n\nto\ mirror\ <a>'s\ state\ at\ the\ time\ the\ event\ happens?\n\n\n**\ Unbound\ `bind`\ **\n**\ Unbound\ \[\[`bind`\]\ **\n\nSome\ of\ the\ best\ `bind`\ coding\ doesn't\ involve\ '''bind'''\ at\ all.\ \ \[DKF\],\nSome\ of\ the\ best\ \[\[`bind`\]\ coding\ doesn't\ involve\ '''bind'''\ at\ all.\ \ \[DKF\],\n\n======\nevent\ add\ <<Copy>>\ <Control-C>\n======\n\ntrumps\n\n======\nbind\ \$class\ <Control-Key-C>\ \[bind\ \$type\ <<Copy>>\]\nbind\ \$class\ <Control-Key-c>\ \[bind\ \$type\ <<Copy>>\]\n======\n\n\n...\ \ \[\[Correct\;\ elaborate\]\]\n\n\n\n**\ `bind`\ to\ a\ plain\ keystroke\ only\ (not\ modified\ by\ Ctrl\ or\ Alt)\ **\n**\ Bind\ to\ a\ plain\ keystroke\ only\ (not\ modified\ by\ Ctrl\ or\ Alt)\ **\n======\nproc\ bind'plainkey\ \{tag\ key\ script\}\ \{\ \n\ \ \ \ bind\ \$tag\ <Control-\$key>\ \{\}\ \n\ \ \ \ bind\ \$tag\ <Control-\$key>\ \{\ \}\ \n\ \ \ \ bind\ \$tag\ <Alt-\$key>\ \ \ \ \ \{\ \}\ \n\}\ \n======\n\nExample:\n\n======\nbind'plainkey\ all\ x\ \{puts\ Hello\}\ \n======\n\n----\n\n\[RUJ\]:\ If\ bind\ leave\ command\ to\ main\ window\ it\ is\ not\ (bindings)\ grabbing\ to\nits\ associated\ widgets.\ e.g.:\ \ \n\n======\ntoplevel\ \$wa\ -bd\ 1\ -relief\ ridge\ntoplevel\ \$wa\ -bd\ 1\ -relief\ ridge\ \;\nwm\ geometry\ \$wa\ 600x40+\$mousex+\$mousey\ \;\nwm\ resizable\ \$wa\ 0\ 0\ \;\nwm\ overrideredirect\ \$wa\ yes\ \;\nwm\ iconname\ \$wa\ \"menu\"\ \;\nwm\ group\ \$wa\ .\ \;\nfocus\ \$wa\ \;\ngrab\ set\ \$wa\ \;\nentry\ \$wa.ent01\ -width\ 6\ -background\ white\ \nentry\ \$wa.ent01\ \\\n\ \ \ \ \ \ \ -width\ 6\ -background\ white\ \nbind\ \$wa\ <1>\ \[list\ after\ cancel\ destroy\ .base\]\n\ \ \ \ \ \ \ \ bind\ \$wa\ <1>\ \[list\ after\ cancel\ destroy\ .base\]\n\ \ \ \ \ \ \ \ bind\ \$wa\ <Leave>\ \[list\ destroy\ .base\]\n======\n\nBut\ it\ is\ destroying\ base\ if\ cursor\ goes\ near\ to\ entry.\ \ Can\ anybody\ solve\ the\nproblem.\n\n\n**\ Disable\ Pasting\ **\n\n2008-03-17:\ How\ can\ I\ disable\ pasting\ into\ a\ text\ widget?\ I\ tried\ the\nfollowing:\n\n======\nbind\ \$theText\ <<Paste>>\ \{tk_messageBox\ -message\ \{Paste\ Attempt\}\}\nbind\ \$theText\ <<Paste>>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\nbind\ \$theText\ <Control-v>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\nbind\ \$theText\ <Button-2>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\nbind\ \$theText\ <Shift-Insert>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\}\n\nThe\ message\ boxes\ are\ shown,\ so\ the\ event\ handling\ works.\ But\ after\ the\ message\nbox\ has\ been\ clicked\ away,\ the\ pasting\ takes\ place\ anyway\ -\ at\ least\ for\nShift-Insert.\n\nAnswer:\ You\ are\ adding\ bindings\ to\ the\ widget\ but\ aren't\ addressing\ the\nbindings\ associated\ with\ the\ widget\ class.\ Read\ up\ on\ `\[bindtags\]`.\ One\ solution\nbindings\ associated\ with\ the\ widget\ class.\ Read\ up\ on\ \[bindtags\].\ One\ solution\nis\ to\ add\ \"\;break\"\ to\ each\ binding\ to\ prevent\ the\ class\ bindings\ from\ firing:\n======\nbind\ \$theText\ <<Paste>>\ \{tk_messageBox\ -message\ \"Paste\ Attempt\"\;\ break\}\n======\n\ \ \nOf\ course,\ you\ can\ also\ just\ set\ the\ -state\ option\ to\ \"disabled\".\n\n\n\n***\ Class\ binding,\ do\ they\ work?\ ***\n\n\[Janic\]:\ 2009-07-01T09:48:17:\n\nI\ tried\ to\ set\ a\ class\ binding\ but\ it\ never\ works.\ For\ example:\n\n======\ncheckbutton\ .a\ -text\ test\npack\ .a\nbind\ .a\ <ButtonPress>\ break\nbind\ .a\ <ButtonPress>\ \"break\"\n\nworks\ fine\ (the\ widget\ is\ still\ active\ but\ you\ can't\ check\ it\ anymore),\ but\ if\nwrite\n\n======\nbind\ Checkbutton\ <ButtonPress>\ break\nbind\ Checkbutton\ <ButtonPress>\ \"break\"\n\nit\ doesn't\ work.\ \ Did\ I\ miss\ something\ in\ the\ class\ binding\ behavior?\n\n\[MG\]:\ Many\ different\ bindings\ are\ checked\ for\ a\ widget,\ based\ on\ its\n\[bindtags\].\ \ The\ default\ order\ for\ a\ widget\ is:\ bindings\ on\ the\ widget\ itself,\nbindings\ on\ its\ class,\ its\ toplevel,\ and\ then\ on\ `all`.\ Also,\ bindings\ are\nbindings\ on\ its\ class,\ its\ toplevel,\ and\ then\ on\ \"all\".\ Also,\ bindings\ are\nkey,\ it\ checks\ for\ KeyPress-a\ before\ a\ more\ generic\ KeyPress,\ etc).\n\nThat's\ why\ you're\ seeing\ what\ you\ see\;\ first\ the\ widget's\ own\ bindings\ are\nchecked,\ and\ the\ generic\ `<ButtonPress>`\ binding\ matches\ and\ is\ run\;\ `\[break\]`\nchecked,\ and\ the\ generic\ <ButtonPress>\ binding\ matches\ and\ is\ run\;\ the\ \[break\]\n\nWhen\ you\ `bind`\ that\ on\ the\ Checkbutton\ class,\ though,\ the\ default\nWhen\ you\ bind\ that\ on\ the\ Checkbutton\ class,\ though,\ the\ default\n<ButtonPress-1>\ binding\ is\ more\ specific,\ and\ gets\ used\ instead\ of\ your\n<ButtonPress>\ binding.\ (You\ can\ see\ all\ the\ default\ bindings\ with\ \[\[bind\nCheckbutton\]\],\ then\ see\ what\ a\ specific\ one\ does\ with\ \[\[bind\ Checkbutton\n\$binding\]\].)\ So,\ to\ override\ the\ default\ binding,\ you'd\ need\ to\ either\ replace\nthe\ Button-1\ binding,\ or\ add\ something\ higher\ up\ the\ \[bindtags\]\ chain.\n\[DKF\]:\ You\ are\ advised\ to\ be\ ''very''\ careful\ with\ changing\ bindings\ of\ widget\nclasses,\ as\ that\ affects\ ''all''\ widgets\ of\ that\ type\ in\ the\ application.\ (It's\nmost\ useful\ if\ you're\ adding\ more\ editing\ keys\ to\ the\ `\[text\]`\ \[widget\],\ or\ are\nmost\ useful\ if\ you're\ adding\ more\ editing\ keys\ to\ the\ \[text\]\ \[widget\],\ or\ are\nmaking\ your\ own\ megawidget\ class.)\ It's\ far\ better\ to\ adjust\ the\ \[bindtags\]\ for\n\n\[wdb\]:\ Here\ an\ example:\ button\ `.b`\ has\ new\ binding\ tag,\ \ `Button1`\ instead\ of\n`Button`.\ \ Bindings\ are\ copied\ from\ `Button`\ to\ `lButton1`,\ then\ binding\ of\n`<1>`\ is\ modified:\n\n===\n%\ package\ require\ Tk\n8.5.1\n%\ pack\ \[button\ .b\ -text\ Howdy\]\n%\ #\ button\ appears\n%\ bindtags\ .b\n.b\ Button\ .\ all\n%\ bindtags\ .b\ \{.b\ Button1\ .\ all\}\n%\ bindtags\ .b\ \".b\ Button1\ .\ all\"\n\ \ foreach\ p\ \[bind\ \$old\]\ \{\n\ \ \ \ \ \ bind\ \$new\ \$p\ \[bind\ \$old\ \$p\]\n\ \ \ \ \}\n\}\}\ Button\ Button1\n%\n%\ bind\ Button1\ <1>\ \"+puts\ yep!\"\n%\ #\ now\ clicking\ on\ .b:\n%\ yep!\n\n%\ \n===\n\nFrom\ now\ on,\ you\ can\ change\ arbitrary\ buttons\ without\ side-effects\ to\ \"normal\"\nbuttons.\n\n\n----\n**\n'''\[telgo\]\ -\ 2010-07-29\ 15:22:47'''\n\[telgo\]\ 2010-07-29\ 15:22:47:\n\n======\nbind\ .\ <Command-f>\ \{\nbind\ .\ <Command-f>\ \{Find\;break\}\n\nI\ also\ have\ a\ menu\ item\ that\ calls\ Find\n\n======\n\$Test\ add\ command\ -label\ Find\ -accel\ Command-F\ -command\ Find\n======\n\n`Find`\ puts\ up\ a\ dialox\ box,\ but\ involves\ some\ sorting.\ However,\ it\nThe\ Find\ procedure\ puts\ up\ a\ dialox\ box,\ but\ involves\ some\ sorting.\ However,\ it\n\n======\nproc\ Find\ \{\}\ \{\n\ \ \ \ global\ body\ dict\ t\n\ \ \ \ \n\ \ \ \ set\ t1\ \[clock\ clicks\ -milliseconds\]\ \ \ \ \ \ \ \ \n\ \ \ \ set\ f\ .dictdisplay\n\ \ \ \ \n\ \ \ \ #see\ if\ we\ want\ to\ restrict\ display\n\ \ \ \ set\ target\ \{\}\n\ \ \ \ if\ \{\[\$t\ tag\ ranges\ sel\]\ ne\ \{\}\}\ \{\n\ \ \ \ if\ \{\ \[\$t\ tag\ ranges\ sel\]\ ne\ \"\"\ \}\ \{\n\ \ \ \ \ \ \ \ set\ target\ \[::soundex::soundex\ \$term\]\n\ \ \ \ \}\ \n\ \ \ \ \n\ \ \ \ if\ \[Dialog_Create\ \$f\ Dictionary\ -borderwidth\ 10\]\ \{\n\ \ \ \ if\ \[Dialog_Create\ \$f\ \"Dictionary\"\ -borderwidth\ 10\]\ \{\n\ \ \ \ \ \ \ \ set\ b\ \[frame\ \$f.buttons\]\n\n\ \ \ \ \ \ \ \ #---------\ convert\ the\ array\ to\ a\ list\n\ \ \ \ \ \ \ \ foreach\ index\ \[array\ names\ dict\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ sort\ \$index\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ sort\ \"\$index\"\n\ \ \ \ \ \ \ \ set\ sorted\ \[WolofSort\ \$sort\]\n\ \ \ \ \ \ \ \ foreach\ item\ \$sorted\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$target\ eq\ \{\}\ ||\ \$target\ eq\ \[::soundex::soundex\ \$item\]\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$text\ insert\ end\ \"\$item\ :\ \$dict(\$item)\\n\"\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ pack\ \$f.body\ \ \$f.buttons\ -side\ top\ -fill\ x\n\ \ \ \ \ \ \ \ button\ \$b.ok\ -text\ OK\ -command\ \{set\ dictdisplay(ok)\ 1\}\n\ \ \ \ \ \ \ \ pack\ \$b.ok\ -side\ right\n\ \ \ \ \}\n\ \ \ \ set\ t2\ \[clock\ clicks\ -milliseconds\]\n\ \ \ \ puts\ \"\[expr\ \{(\$t2-\$t1)/1000.0\}\]\ seconds\"\n\ \ \ \ puts\ \"\[expr\ (\$t2-\$t1)/1000.0\]\ seconds\"\n\ \ \ \ set\ dictdisplay(ok)\ 0\n\ \ \ \ Dialog_Wait\ \$f\ dictdisplay(ok)\ \n\ \ \ \ \n\ \ \ \ set\ t3\ \[clock\ clicks\ -milliseconds\]\n\ \ \ \ puts\ \"\[expr\ \{(\$t3-\$t2)/1000\}\]\ seconds\"\n\ \ \ \ puts\ \"\[expr\ (\$t3-\$t2)/1000\]\ seconds\"\n\}\n======\n\nIf\ I\ use\ the\ menu\ item,\ everything\ works\ as\ expected.\ If\ I\ use\ Command-f,\ there\nis\ a\ noticeable\ pause,\ then\ the\ dialog\ appears\ -\ undecorated\ -\ with\ the\ data\ in\nit\ and\ the\ ok\ button,\ but\ never\ returns\ from\ Dialog_Create.\ `Dialog_Create`,\nit\ and\ the\ ok\ button,\ but\ never\ returns\ from\ Dialog_Create.\ \[Dialog_Create,\nDialog_Wait\ and\ Dialog_Dismiss\ are\ taken\ from\ Welch,\ Jones\ and\ Hobbs\ 2003\n\nIs\ there\ an\ issue\ with\ putting\ up\ a\ dialog\ box\ from\ within\ a\ key-binding?\n\n<<discussion>>} CALL {my revision bind} CALL {::oo::Obj2367869 process revision/bind} CALL {::oo::Obj2367867 process}

-errorcode

NONE

-errorinfo

wrong # args: should be "string replace string first last ?string?"
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4