Sie sind nicht angemeldet.

herrpedro

Fortgeschrittener

  • »herrpedro« ist der Autor dieses Themas

Beiträge: 210

Wohnort: Lisbon

Beruf: Programmer/analyst

  • Nachricht senden

1

Montag, 16. Dezember 2019, 12:31

handling hotspot and layer click in general

hi all,

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"... )?

Thank you.

herrpedro

Fortgeschrittener

  • »herrpedro« ist der Autor dieses Themas

Beiträge: 210

Wohnort: Lisbon

Beruf: Programmer/analyst

  • Nachricht senden

3

Montag, 16. Dezember 2019, 14:17



Thank you for your reply but...
If I add that line will it affect all the layers and hotpots in a tour instantly?

Like
<event onClick="trace(clicked) " > affects all click

Same thing for clicking a hotspot without adding styles or onclicks to all of them

Scott Witte

Fortgeschrittener

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

4

Montag, 23. Dezember 2019, 16:28

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.

I haven't tested this but seems it should work.

5

Montag, 23. Dezember 2019, 16:35


Thank you for your reply but...
If I add that line will it affect all the layers and hotpots in a tour instantly?


No, it will affect only the layer you add it to.

<layer name="mybutton" .... onclick="trace('whee, i was clicked!');" />

6

Montag, 20. April 2020, 00:49

Hey,

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)


7

Montag, 20. April 2020, 00:51

Quellcode

1
2
3
for (set(p,0), p LT style.count, inc(p), 
    style[get(p)].addevent(onclick, get(onclickcmd) );
);


Quellcode

1
2
3
for (set(p,0), p LT style.count, inc(p), 
set(style[get(p)].onclick.addevent, get(onclickcmd) );
);


neither seems to be working unfortunately

Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von »lerayfle« (20. April 2020, 01:41)