Cay Horstmann wrote:
> Ok, here is what I came up with. It doesn't do autocomplete, but it is a
> start.
> 
>   <binding>
>     <keyPressed code="ESCAPE" />
>     <charTyped char="K" />
>     <command name="setClass"/>
>   </binding>
> 
>    <command name="setClass">
>      <macro>
>        <sequence>
>          <command name="prompt"
>                   parameter="Question class"/>
>          <command name="putAttribute"
>                   parameter="[implicitElement] class %_"/>
>        </sequence>
>      </macro>
>    </command>
> 
> I didn't see why I'd need to use the "pass" construct, but maybe that's
> for more complex macros that can fail in the middle?

Why prompt the user when the selected element has no "class" attribute?
In such case, it is nicer to ``disable'' the command. This is easily
done by inserting a <pass> element:

---
   <command name="setClass">
     <macro>
       <sequence>
         <pass><command name="putAttribute"
                 parameter="[implicitElement] class"/></pass>
         <command name="prompt"
                  parameter="Question class"/>
         <command name="putAttribute"
                  parameter="[implicitElement] class %_"/>
       </sequence>
     </macro>
   </command>
---

See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_reference.html

Note that if you intend to use command "prompt" instead of command
"pick" (i.e. "pick" with a fixed list of classes), there is no need to
write a macro. Simply bind "Esc K" to:

---
  <command name="putAttribute"
           parameter="[implicitElement] class"/>
---


Reply via email to