You are not logged in.

jmulder

Beginner

  • "jmulder" started this thread

Posts: 17

Location: Amsterdam, Netherlands

  • Send private message

1

Wednesday, September 22nd 2010, 9:40am

Mouse event bubbling between plugins with 'enable' and 'capture' and hotspots

Searching the forum regarding the correct use of the 'enable' and 'capture' properties for plugins didn't give me much, so I decided to create a new thread. I seem to be having problems with using the aforementioned properties and having mouse events bubble through to any hotspots that are underneath it.

The documentation mentions:

Quoted

.. when "enabled=true" and "capture=false" then the mouse events are sent to the plugin and also to all underlying objects ...


From searching the forum Klaus mentioned that with "underlying objects" he meant hotspots and the krpano object itself. Taking this explanation I would have assumed the following works, but it doesn't seem to.

My situation is as follows (unfortunately I cannot provide working examples):

Plugin
I want to have an action executed whenever someone 'onmouseover' the entire Krpano viewer. To do this I created the following plugin:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<plugin name="fsoverlay"
	url="/img/misc/bg-grey-100.png"
	align="lefttop"
	x="0"
	y="0"
	width="2000"
	height="2000"
	alpha="0"
	zorder="0"
	handcursor="false"
	capture="false"
	enabled="true"
	onover="fshover(true)"
	onout="fshover(false)"
	onhover="if(get(fullscreen), fshover(false))"
/>


Hotspots
Naturally I want hotspots in the viewer as well. As such, mouse events on the 'fshover' plugin needs to bubble through to all underlying objects. I would have assumed the above settings for the 'capture' and 'enabled' properties would work, but it does not.

Any help would be greatly appreciated! If you need more (or just a better) explanation, then let me know.

jmulder

Beginner

  • "jmulder" started this thread

Posts: 17

Location: Amsterdam, Netherlands

  • Send private message

2

Tuesday, October 5th 2010, 2:16pm

Just a small update for future reference, I managed to more or less solve the problem but only specifically for my case. In my situation I needed a plugin overlaying the complete viewer, but the only interactive part was positioned as a small button in the top right corner.

Note: This is just a big workaround and does not actually solve the problem related to mouse event bubbling.

The implemented workaround is as follows:

plugin[fsborder] with enabled=false, capture=false
This effectively just makes it decorative and allows all other hotspots to work just fine as if nothing else is there. The plugin itself uses the resizeEvent to calculate the dimensions and resizes the plugin accordingly. This plugin has all the Actionscript for the hover and click functionality

plugin[fsbutton]
The aforementioned plugin dynamically adds this plugin, so we can store a reference to the event handlers in the plugin's properties:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//
// Register plugin
//
function registerEvent (e:DataEvent):void {
	// Get plugin data
	p = krpano.get(e.data);
	
	// Add transparant plugin as a proxy
	krpano.call('addplugin(fsbutton)');
	krpano.call('plugin[fsbutton].loadstyle(control)');
	krpano.set('plugin[fsbutton].keep', 'true');
	krpano.set('plugin[fsbutton].height', '26');
	krpano.set('plugin[fsbutton].width', '26');
	krpano.set('plugin[fsbutton].align', 'righttop');
	krpano.set('plugin[fsbutton].x', '0');
	krpano.set('plugin[fsbutton].y', '0');
	
	// Proxy events
	krpano.set('plugin[fsbutton].onover', onRollOverEvent);
	krpano.set('plugin[fsbutton].onout', onRollOutEvent);
	krpano.set('plugin[fsbutton].onclick', onClickEvent);
}


Edit: The methods onRollOverEvent and such are within the same Flash plugin. Their signature require to expect no arguments, unlike conventional event handlers assigned through Actionscript itself.

Truly love how internally it all are just variables and all plugins can reference eachother through Krpano.

Hiding/showing the plugin using Javascript
Finally, the Javascript applies a simple hover behaviour on the SWF element, which calls the Krpano interface and tells it to hide or show the plugin.