Pages: 1
Print
Author Topic: XMetaL v4.6 - Reload image after editing  (Read 1170 times)
brad_deteau
Member

Posts: 5


« on: June 07, 2010, 03:40:02 PM »

How do I reload an image after editing the source on my hard drive?  The only way I have been able to get around this is to rename the image file name.  Otherwise, I see the old image.

I read how to write a script ...

//XMetaL Script Language JScript:
//Select the image before running this script...
rng = ActiveDocument.Range;
rng.CollapsedContainerTags = true;
Application.Alert("collapsed");
rng.CollapsedContainerTags = false;

There is also ActiveDocument.Reload() but that reloads the document from disc.

... but I'm not a programmer ... just a DA user.  Maybe it's time for a quick tutorial on how to incorporate this script.

Thanks in advance gurus,
Brad
Logged
dcramer
Member

Posts: 120


« Reply #1 on: June 07, 2010, 03:51:20 PM »

Yes, that's the way to do it (I believe the code snippet you found was Derek's answer to my question). Add a macro to reload the image. In my case the image element name is imagedata:

Code:
<MACRO name="Reload Current Image" lang="JScript" desc="Custom macro." hide="false"><![CDATA[// XMetal Author JScript Macro File
  if (rng.ContainerName == "imagedata") {
rng = ActiveDocument.Range;
rng.CollapsedContainerTags = true;
//Application.Alert("collapsed");
rng.CollapsedContainerTags = false;
    }
                                                                                                           
]]></MACRO>

And then add an item to the contextual menu:

Code:
<MACRO name="On_Context_Menu" lang="JScript" hide="true"><![CDATA[var rng = ActiveDocument.Range;
var curNode = rng.ContainerNode;


if (rng.ContainerName=="imagedata" && rng.ContainerNode.hasAttribute("fileref")) {

   Application.AppendMacro("&Reload Current Image","Reload Current Image");
}
             
]]></MACRO>

Now the user can right-click on the image and select "Reload Current Image".

Adjust for the names of the elements in your dtd.

David
Logged

David Cramer
Technical Writer
Motive, an Alcatel-Lucent Company
brad_deteau
Member

Posts: 5


« Reply #2 on: June 07, 2010, 04:00:03 PM »

Thanks for the quick reply, David.

I've never added a macro, nor edited the contextual menu.

I see how to record a macro, but not add one.  Can you detail the steps for me?  I would be much obliged to ya.

B

Logged
Pages: 1
Print
Jump to: