Jump to content


Photo

CustomData Inspector


  • Please log in to reply
4 replies to this topic

#1 senocular

senocular

    Fireworks Extender

  • Administrators
  • PipPipPipPipPip
  • 150 posts
  • Location:San Francisco, CA (USA)

Posted 23 September 2006 - 06:32 AM

Each object on the canvas in Fireworks has a hidden property that allows users (usually command or extension developers) to save custom data to that object. This property is called, not surprisingly, customData. Lately I've been working with a lot of customData to manage the exporting of text-based (non-html) content from Fireworks. Normally I use my Command Prompt extension for this, but given the extent to which I've been relying on custom data, I decided to make a very simple inspector panel that provides access to the custom data of a selection.

The CustomData Inspector panel lets you view and edit all non-object properties within the customData object of your selection. If object properties exist within the customData object (complex property values like objects or arrays), they are simply not displayed and the panel locks you out from overwriting them with other properties. If you have more than one object selected, only the customData of the first object selected is displayed. Make new properties using the + icon; delete selected properties with the trashcan icon. Note: Holding CTRL while clicking on the delete icon will bypass the confirmation dialog. You can edit both property values and their names, though tabbing will cycle only through property values.

You may find this useful when working with your own extensions or just to see if you have any commands or extensions that might secretly add data to an object when used. Hint: All Auto Shape tools use customData to work with the Auto Shape Properties panel ;)

This is Fireworks 8 only. No installer is provided; you must copy the SWF into your Fireworks/Configuration/ Command Panels directory.

http://www.senocular...20Inspector.swf


Additionally, I have a command that lets you paste custom data from one object to another much in the same way Edit > Paste Attributes works. Just select the object with the custom data you want to duplicate, copy it to the clipboard, select the object you want to have the data duplicated to, and run this command. Note: any previous data will be lost. As with the custom data panel, you will have to copy this file into your commands directory.

http://www.senocular...0CustomData.jsf

#2 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 23 September 2006 - 02:50 PM

Well done, man.

Scrollbar might be nice :)

#3 senocular

senocular

    Fireworks Extender

  • Administrators
  • PipPipPipPipPip
  • 150 posts
  • Location:San Francisco, CA (USA)

Posted 23 September 2006 - 03:45 PM

Heh, thats why I said "very simple" ;)

#4 lungdisc

lungdisc

    FireworksCommander

  • Members
  • Pip
  • 7 posts

Posted 24 November 2011 - 01:23 PM

Hi,

I'm working on a similar extension myself. The problem is that customData variable names can not hold signs like "-, ( / etc".
The only non-alphanumeric character that is allowed is the "_" (underscore) sign.

Example:
allowed ==> obj.customData[background_color] = "string";
not allowed ==> obj.customData[background-color] = "string";

#5 jdunning

jdunning

    Fireworks Ninja

  • Members
  • PipPipPipPipPip
  • 173 posts

Posted 22 March 2012 - 06:51 PM

I'm working on a similar extension myself. The problem is that customData variable names can not hold signs like "-, ( / etc".
The only non-alphanumeric character that is allowed is the "_" (underscore) sign.

Example:
allowed ==> obj.customData[background_color] = "string";
not allowed ==> obj.customData[background-color] = "string";

Your examples need quotes around the keys to work with standard JS objects:

var o = {};
o["background-color"] = "foo";
alert(o["background-color"]); // foo
Unfortunately, customData isn't a regular object. It's a FwDict object, which kind of looks like a JS object but doesn't behave the same. In particular, it doesn't seem to allow keys that contain anything but normal characters:

var o = new FwDict();
o["background-color"] = "foo";  // throws an error
The only way to store keys like that on customData seems to be to turn the data you're storing into a JSON string first, and then store the string. You'll need to parse the string back into a real object when you want to access the data.