Is there a way to create a generic event that so that a click in a hotspot or layer triggers my custom event ?
Like adding a tracelog saying "hotspot gotoKitchen was clicked" or "layer layerThumbs was clicked" without cycling through all of them with .addevent("onclick"... )?
Personally I hard code such tracing into the buttons I want to monitor, but if you want something more generic I would suggest using the events.onclick that you mentioned above. In the action triggered you can report or trace back the name of the layer or hotspot clicked. You can filter for just those that have their own onclick events or any other type of filtering.
Code to dynamically set the event on all hotspots and layers.
Quellcode
1
2
3
4
5
6
7
set(onclickcmd, "trace('it works');");
for (set(p,0), p LT hotspot.count, inc(p),
hotspot[get(p)].addevent(onclick, get(onclickcmd) );
);
for (set(p,0), p LT layer.count, inc(p),
layer[get(p)].addevent(onclick, get(onclickcmd) );
);
Unfortunately, if you're using the "addhotspot" action, then this won't work very nicely : it only sets the event on already existing hotspots and layers. So if you create a hotspot on the go for instance, then the addevent won't be set unless you set it in the style (hard-coded)
Dieser Beitrag wurde bereits 6 mal editiert, zuletzt von »lerayfle« (20. April 2020, 01:39)