Quantcast
Channel: Serif Software Forums (Closed) - WebPlus
Viewing all articles
Browse latest Browse all 4745

WebPlus X6: Graphic action return ID's

$
0
0
Not sure if this has been posted before but here goes.

I wanted to place an action on a graphic asset. The code behind the action relied on the ID of the graphic via a 'this.id' parameter in the custom code call.

Unfortunately giving the graphic an ID is not reliable. If you leave the graphic as a Serif .smf the ID returned by the action is not the ID you set but the ID given internally by WPX6, typically map0_1 or similar, depending on how many other graphic assets you have. If you convert the graphic to a picture if you choose PNG with transparent background the situation is the same. Non transparent background or Gif or Jpeg choices do return the ID set by you. Generic code to decide where an action came from starts to get messy.

The graphic image holds the ID you set but if there is a <map> tag associated with the graphic then the action returns the map ID.

It is probably best to use a properly designed DIY button and stick your own arrow design or whatever on it within the editor. The button editor converts any designs you impose into a sprite so there is no messing about with map coordinates so you get the ID you asked for if you need it.

Most users will never come across this, as they will rely on WP to add the appropriate code when they say place a close graphic on a panel. It isn't usually necessary for the user to specify an ID then, just to add the onclick visibilty action say. If you do examine what happens then as above an internal map ID is returned. WP adds event code like
Code:

addEvent('map0_1','click',function(){MyIDCheck(this.id)});
without the user being aware whereas you would prefer
Code:

addEvent('MyID','click',function(){MyIDCheck(this.id)}).
Converting your graphic to a non transparent block to avoid the ID return issue may not be nice to look at, so a properly designed button is best for those situations if you need a proper ID returned.

John B

Viewing all articles
Browse latest Browse all 4745

Trending Articles