Pratik Pattanayak
Pratik Pattanayak

Reputation: 194

Firebreath: Multiple event listeners to one firebreath event in windowed plugin

I created a demo JS code to check mousedown event handling.

For a normal dom element the mousdown should alert 1 and 2. Why isn't it the same case as that of windowed plugin, where I have subscribed 2 event handlers to one Plugin mousedown event?

Its only firing the alert box displaying message '1'.How can I achieve the plugin to display 2nd alert box also displaying message '2' on this single mousedown event on IE9,11,8,Chrome and firefox.

<script type="text/javascript">
    function plugin0()
    {
        return document.getElementById('plugin0');
    }
    plugin = plugin0;
    function addEvent(obj, name, func)
    {
        if (obj.attachEvent) {
            obj.attachEvent("on"+name, func);
        } else {
            obj.addEventListener(name, func, false); 
        }
    }

    function load()
    {
        addEvent(plugin(), 'OnMouseDown', function(){
            alert("1.")
        });
       addEvent(plugin(), 'OnMouseDown', function(){
            alert("2.")
        });
    }

    function pluginLoaded() {
        alert("Plugin loaded!");

    }

    function pluginValid()
    {
        if(plugin().valid){
            alert(plugin().echo("This plugin seems to be working!"));
        } else {
            alert("Plugin is not working :(");
        }
    }


 </script>
<body onload="load()">
<object id="plugin0" type="application/x-windowedPlugin" width="300" height="300">
    <param name="onload" value="pluginLoaded" />
</object><br />

Upvotes: 4

Views: 130

Answers (1)

taxilian
taxilian

Reputation: 14324

well, for one thing the event should be all lowercase. The event shouldn't have "on" in it either. Not seeing your C++ code here it's hard to say what else your problem may be.

Upvotes: 1

Related Questions