David Flanagan wrote: > I'm trying to write a macro and key binding to simplify the insertion of > cross references: > > <command name="djf.InsertXref"> > <macro> > <sequence> > <command name="insert" parameter="into xref"/> > <command name="prompt" parameter='XREF "Enter xref ID:"'/> > <command name="putAttribute" parameter="linkend %_"/> > </sequence> > </macro> > </command> > > <!-- Ctrl-C R: insert a cross reference <xref> prompt for linkend. --> > <binding> > <keyPressed code="C" modifiers="ctrl"/> > <keyPressed code="R"/> > <command name="djf.InsertXref"/> > </binding> > > It doesn't work. The xref gets inserted, and I get prompted for the > parameter value, but the default ??? value of the linkend attribute > never changes. Furthermore, when I execute this command the letter R is > inserted after the xref. (The second key of my key binding is just R > with no modifiers, but I've used this style of binding for other > commands without problem.) > > However, if I change the binding from Ctrl-C R to Ctrl-C Ctrl-R, then it > works. My hypothesis is that somehow the insert command is broken when > bound to a key that is insertable. When the letter R gets inserted my > new xref element is no longer selected (although it does appear > selected) and the putAttribute call fails.
Your analysis is correct. > Anyway, it looks like a bug to me. An XXE bug? A Java[tm] bug? Not easy to fix this one... A simple and clean workaround is to use: --- <charTyped char="r"/> --- instead of: --- <keyPressed code="R"/> --- ======================== PS: You should remove: --- <command name="prompt" parameter='XREF "Enter xref ID:"'/> --- in order to give a try to: --- <command name="putAttribute" parameter="linkend"/> ---

