in 37 minutes<br />XMetaL Dialog Programming <br />Odds & Ends<br />Murray Smith, Director of Technical Services<br />Brou...
Announcements<br />Next time: Derek Read will talk about <br />DITA Open Toolkit Deployment with XMetaL Author Enterprise ...
Introduction to XMetaL Dialogs<br />Displaying your dialog from a menu button,<br />Built-in XMetaL dialogs,<br />Building...
Displaying Your Dialog From a Menu Button<br />Step 1<br />The OnAction property of the menu button is associated with an ...
Displaying Your Dialog From a Menu Button<br />Step 2<br />The XMetaL macro associated with the menu button will create th...
Built-in XMetaL Dialogs<br />XMetaL Author supports a number of built-in dialogs.<br />Alert: displays a message, with an ...
Built-in Dialogs – cont.<br />The built-in dialogs are very easy to use.<br />Example display an Alert:<br />Application.A...
Building Custom Dialogs<br />Custom dialogs are built in the XMetaL Form Layout Tool (XFLayout) which is part of the XMeta...
Building Custom Dialogs – cont.<br />After adding the dialog controls by dragging and dropping them on the form using the ...
Passing Objects to Your Dialog<br />This is simple. The script to create your dialog and display it is just slightly diffe...
Passing Objects to Your Dialog – cont.<br />In the script code inside your dialog, you access the object using the name gi...
Passing Objects to Your Dialog – cont.<br />Note: When using this approach to create your dialog, you need to explicitly p...
Options for Where Your Dialog Code Will Live<br />Given that we can pass JavaScript objects to the dialog, the next logica...
Options for Where Your Dialog Code Will Live – cont.<br />Advantages<br />Script code is more easily viewed. (In the XFLay...
Summary<br />We’ve looked at some introductory topics related to dialogs in XMetaL Author.<br />Launching a dialog from a ...
Thank you for attending!<br />Q&A<br />
Upcoming SlideShare
Loading in …5
×

XMetaL Dialog Odds & Ends

1,775 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,775
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

XMetaL Dialog Odds & Ends

  1. 1. in 37 minutes<br />XMetaL Dialog Programming <br />Odds & Ends<br />Murray Smith, Director of Technical Services<br />Brought to you by XMetaL Technical Services<br />
  2. 2. Announcements<br />Next time: Derek Read will talk about <br />DITA Open Toolkit Deployment with XMetaL Author Enterprise 6.0<br />
  3. 3. Introduction to XMetaL Dialogs<br />Displaying your dialog from a menu button,<br />Built-in XMetaL dialogs,<br />Building a custom dialog,<br />Passing objects from your macro code to the dialog,<br />Options for where your dialog code will live.<br />Agenda<br />
  4. 4. Displaying Your Dialog From a Menu Button<br />Step 1<br />The OnAction property of the menu button is associated with an XMetaL Macro.<br />exampleMenu = Application.CommandBars.item( "Menu bar" ).Controls.Add(MENU_BUTTON_TYPE, null); <br />exampleMenu.Caption = 'Example 1';<br />var example1Menu = exampleMenu.Controls.Add(sqcbcTypePopup);<br />example1Menu.Caption = 'Run Example 1';<br />example1Menu.FaceId = 0;<br />example1Menu.DescriptionText = 'Display Ex. 1 Dialog.';<br />example1Menu.OnAction = "ShowExample1Dialog";<br />
  5. 5. Displaying Your Dialog From a Menu Button<br />Step 2<br />The XMetaL macro associated with the menu button will create the dialog and display it by calling it’s DoModal() method.<br /><MACRO name="ShowExample1Dialog" hide="true" lang="JScript"><br /><![CDATA[<br /> // XMetaL Script Language JSCRIPT:<br /> var XMetaLPath = Application.Path;<br /> var xftPath = XMetaLPath + "FTxample1.xft";<br />var dlg=Application.CreateFormDlg( xftPath );<br /> dlg.DoModal();<br /> dlg=null;<br /> ]]><br /></MACRO><br />
  6. 6. Built-in XMetaL Dialogs<br />XMetaL Author supports a number of built-in dialogs.<br />Alert: displays a message, with an ok button.<br />Prompt: displays a message, and a text field for input.<br />Confirm: displays a message, and ok & cancel buttons.<br />NoticeBox: displays a message, and up to 3 buttons.<br />MessageBox: Displays a message, a variety of buttons, and a variety of icons.<br />Buttons: Ok, Ok/Cancel, Abort/Retry/Ignore, Yes/No, Yes/No/Cancel, Retry/Cancel.<br />Icons: Critical, Warning Query, Warning Message, Info Message.<br />
  7. 7. Built-in Dialogs – cont.<br />The built-in dialogs are very easy to use.<br />Example display an Alert:<br />Application.Alert( "This is my message." );<br />Example display a NoticeBox:<br />var response = Application.NoticeBox( "What is your favorite fruit?", "Apple", "Orange", "I don't like fruit." );<br />if( response == 1 ){<br /> Application.Alert( "You like apples." );<br />}<br />else if( response == 2 ){<br /> Application.Alert( "You like oranges." );<br />}<br />else{<br /> Application.Alert( "You don't like fruit?" );<br />}<br />
  8. 8. Building Custom Dialogs<br />Custom dialogs are built in the XMetaL Form Layout Tool (XFLayout) which is part of the XMetaL Developer product.<br />
  9. 9. Building Custom Dialogs – cont.<br />After adding the dialog controls by dragging and dropping them on the form using the layout tool, you can add behavior to the controls by adding code to the desired event.<br />
  10. 10. Passing Objects to Your Dialog<br />This is simple. The script to create your dialog and display it is just slightly different from the approach we saw in example 1.<br />var listEntries = new Array( "I don't like fruit", "Apple", "Orange", "Peach", "Pineapple" );<br />var returnVal = new Object();<br />returnVal.response = 0;<br />var xftPath = Application.Path + "FTxample4.xft"; <br />var xft = new ActiveXObject("XF.XFTForm"); <br />xft.AddTopLevelObject( "fruitOptions", listEntries );<br />xft.AddTopLevelObject( "returnVal", returnVal );<br />xft.AddTopLevelObject( "Application", Application );<br />var dlg = xft.StartForm( xftPath, 0 );<br />if( dlg.DoModal() == 1 )<br />{<br /> Application.Alert( "You said: " + listEntries[returnVal.response] );<br />}<br />dlg = null;<br />xft = null;<br />listEntries = null;<br />
  11. 11. Passing Objects to Your Dialog – cont.<br />In the script code inside your dialog, you access the object using the name given to it when calling AddTopLevelObject().<br />xft.AddTopLevelObject( "fruitOptions", listEntries );<br />xft.AddTopLevelObject( "returnVal", returnVal );<br />xft.AddTopLevelObject( "Application", Application );<br />
  12. 12. Passing Objects to Your Dialog – cont.<br />Note: When using this approach to create your dialog, you need to explicitly pass the Application object to the dialog in order to be able to access it from your dialog code.<br />xft.AddTopLevelObject( "Application", Application );<br />
  13. 13. Options for Where Your Dialog Code Will Live<br />Given that we can pass JavaScript objects to the dialog, the next logical question is whether we could pass a JavaScript object that implements the dialog behavior.<br />Event scripts in the XFT call methods on the JavaScript object<br />
  14. 14. Options for Where Your Dialog Code Will Live – cont.<br />Advantages<br />Script code is more easily viewed. (In the XFLayout tool you can only view the code for one event macro at a time.)<br />Since the JavaScript object is instantiated in XMetaL Author’s script engine, you have access to the script debugger in your code by adding a “debugger;” statement.<br />Further if you pass XFT controls into those methods, you can view the property values for those controls at run time. (Whereas, if the code is all in the XFT you will need to use Alerts to be able to view the property values.)<br />
  15. 15. Summary<br />We’ve looked at some introductory topics related to dialogs in XMetaL Author.<br />Launching a dialog from a menu item,<br />The built-in dialogs in XMetaL Author,<br />Creating a custom dialog.<br />Then we built on that to look at some more advanced topics.<br />Passing JavaScript objects to you dialog,<br />An interesting approach to structuring your dialog script code.<br />
  16. 16. Thank you for attending!<br />Q&A<br />

×