General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion May I get automatic enter key when typing to XMetal Author?

  • biswajitsr

    May I get automatic enter key when typing to XMetal Author?

    Participants 0
    Replies 1
    Last Activity 12 years, 6 months ago

    I am using XMetal Author. I need after every 80 characters there will appear one enter to create new paragraph automatically. Is it possible at all? In response to my another question I get information from this forum that there is no onkeypress like event available. Only On_Update_UI event is the nearest to it, but it will not fulfill this requirement. So is it possible in any other way? Thanks in advance.


    Derek Read

    Reply to: May I get automatic enter key when typing to XMetal Author?

    Do you mean you have an element where carriage returns are relevant, and need to be inserted every 80 characters?

    If so, this could be handled various ways. Here are some thoughts…

    1) Allow the author to type freely within the element and not worry about carriage returns at all. Then modify the document before saving (good events for this are On_Before_Document_Validate or On_Before_Document_Save) by walking through it, finding each relevant element and making changes to its PCDATA content using script.

    2) Implement an XFT form containing a “MultiEditBox” control together with script inside the form that inserts carriage returns at the relevant locations (and possibly strips others out). You might render the form inline (embedded) and style it so that the author feels they are editing this element as if it was a regular element and typing directly into the document. This would only work for Tags On and Normal view. In addition, you should avoid this option if your documents will contain many of these elements as using too many embedded XFT forms in a document can slow editing down (each one gets its own separate Windows Script Engine and associated memory and CPU overhead, this is analogous to running several copies of Internet Explorer at one time).

    3) Handle this outside of XMetaL (after saving) using XSLT or other type of transformation. The author would then (similar to #1) not worry about the content of these elements at all and the carriage returns would be inserted automatically (and they might never even know about it). It can often be a good idea to separate this type of thing from the authoring process completely when the user should have no control over it as they will then not waste time concerning themselves asking “did this particular line get wrapped properly during editing”.

    4) You might be able to do this with Pretty Printing. You would need to turn pretty printing on in the CTM file, set the global MaxLineLength property to 80 characters (which is in fact the default value), then probably disable indenting for the elements in question. Finally, you'd probably need to set  and for the element. I have not tried this but it should be possible to get this working. Note that if you have other elements in the document that you do not want to line wrap at 80 characters you would need to set the property for each of those.

    Note that if you wish the author to be able to see these significant carriage returns (and you are not embedding an XFT form into the document) you will need to set the CSS property “white-space:pre” for the relevant element(s). Keep in mind that this does not affect the font being used, just whether or not white-spaces are displayed to the author (so if you wish to use a monospaced font to mimic the HTML “pre” for example, you would need to specifically set that with a font-family CSS property.


  • You must be logged in to reply to this topic.

Lost Your Password?