XMetaL Tips and Tricks

XMetaL Community Forum XMetaL Tips and Tricks Script Example: Imitating Checkboxes with Script, CSS and Images

  • Derek Read

    Script Example: Imitating Checkboxes with Script, CSS and Images

    Participants 1
    Replies 2
    Last Activity 10 years, 9 months ago

    XMetaL Author (Enterprise and Essential) and XMAX
    Tested with XMetaL Author Enterprise and

    Background and Purpose:
    This sample is in response to a question on the forum about whether it is possible to “[url=http://forums.xmetal.com/index.php/topic,2258.0.html]create checkboxes[/url]”.

    This sample shows how you might allow an author to change attribute values outside the Attribute Inspector and without the use of XFT. It shows how various actions might be used, including single and double click, or pressing the spacebar. It also demonstrates how to attach shortcut keys to macros, how to override default shortcuts while retaining their standard functionality in a given context and little bit of fancy CSS.

    Whether this type of solution will be useful for any particular set of authors working with a particular schema is hard to say since the DTD used in this demo is contrived in order to make the sample as simple as possible. For most XMetaL customization developers, the best solution will often be to use a modal XFT dialog for most user interactions involving the setting of attributes (when your users do not wish to use the Attribute Inspector or you need to provide guidance in setting attributes that the Attribute Inspector cannot not provide). XFT allows you to create complex forms that include all the standard controls users expect to be able to interact with (including checkboxes, radio buttons, listboxes, textboxes, etc). See the [url=http://na.justsystems.com/webhelp/en/xmetaldeveloper/cg/6.0/cg.html#XMetaL%20Forms%20Toolkit]Customization Guide topic titled “XMetaL Forms Toolkit”[/url] for more information.

    * Licensed Materials – Property of JustSystems, Canada, Inc.
    * (c) Copyright JustSystems Canada, Inc. 2012
    * All rights reserved.
    * The sample contained herein is provided to you “AS IS”.
    * It is furnished by JustSystems Corporation as a simple example and has not been
    * thoroughly tested under all conditions. JustSystems Canada, Inc., therefore, cannot
    * guarantee its reliability, serviceability or functionality.
    * This sample may include the names of individuals, companies, brands and products
    * in order to illustrate concepts as completely as possible. All of these names are
    * fictitious and any similarity to the names and addresses used by actual persons or
    * business enterprises is entirely coincidental.

    Unzip the contents of the attached zip file into an empty folder and open the XML file included with the sample.
    Basic instructions on functionality are included as text at the start of the sample and the script in the MCR file should be self-explanatory for anyone that has had a look at the XMetaL Developer Programmers Guide.

    Minor bug in the code. The event On_Mouse_Over in the MCR file will fire whether a document is open or not. However, the code it contains is written to run on an open document so when no documents are open it will throw a runtime error. Wrapping the script in an extra if statement will fix that:

    if (Documents.Count > 0) {
      ...existing code...



    Reply to: Script Example: Imitating Checkboxes with Script, CSS and Images

    Hi Derek

    Thanks for the reply.

    Instead of double click can we able to do in single click  Is that possible.



    Derek Read

    Reply to: Script Example: Imitating Checkboxes with Script, CSS and Images

    Yes. You should read the Programmers Guide to see which events the product supports. There is an On_Click event.


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

Lost Your Password?