Pages: 1
Print
Author Topic: Script Example: Imitating Checkboxes with Script, CSS and Images  (Read 4183 times)
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2484



WWW
« on: April 25, 2012, 01:14:22 PM »

Products:
XMetaL Author (Enterprise and Essential) and XMAX
Tested with XMetaL Author Enterprise 6.0.2.070 and 7.0.0.073

Background and Purpose:
This sample is in response to a question on the forum about whether it is possible to "create checkboxes".

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 Customization Guide topic titled "XMetaL Forms Toolkit" for more information.

Legal:
* 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.
*---------------------------------------------------------------------

Usage:
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.

Updates:
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:

<MACRO name="On_Mouse_Over" lang="JScript" hide="true"><![CDATA[
if (Documents.Count > 0) {
  ...existing code...
}
]]></MACRO>


* checkbox_demo.jpg (61.03 KB, 614x706 - viewed 573 times.)
* checkbox_demo.zip (3.53 KB - downloaded 223 times.)
« Last Edit: April 27, 2012, 10:38:59 AM by Derek Read » Logged
karthic2861
Member

Posts: 22


« Reply #1 on: April 26, 2012, 12:30:55 PM »

Hi Derek

Thanks for the reply.

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

Thanks
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2484



WWW
« Reply #2 on: April 26, 2012, 02:35:56 PM »

Yes. You should read the Programmers Guide to see which events the product supports. There is an On_Click event.
Logged
Pages: 1
Print
Jump to:  

email us