z-index with <object> and <g:background>

I'm nearing completion of my gadget, but I have one last feature which is stalling me.

My gadget is using an ActiveX control to stream video from a webcam. Everything is working great, however I'm running into the old problem of not being able to catch onclick events on the <object> tag. My workaround so far has been to use onmouseover, which works fine, but it is less than perfect.

While messing around with g:background, however, I noticed that if the z-index is higher than the z-index of the ActiveX object, I suddenly can right-click on the object and get the normal gadget context menu. Usually, that does not work. Also, the onmouseover event on the object stops firing, which leads me to believe that in some way the g:background is layering over the object. However, setting up onclick events with g:background still doesn't get me anywhere.

Does anyone have any idea why g:background seems to have this pseduo-functionality It seems odd to me that placing it over the object gives me partial functionality, while still not letting me catch the mouse events.

Thanks for any help.


Answer this question

z-index with <object> and <g:background>

  • aztec2_step

    I don't think it's going to be productive to try and use g:background to solve any event-driven issues you have; I'd rather figure out why onclick isn't working on the <object> tag. Is this something that works OK if you try it in IE
  • Tryin2Bgood

    If the ActiveX object you are using doesn't natively support passing click events through to its surrounding HTML, then perhaps you're right to seek hacky workarounds - I don't know of a "correct" way to do it, if the ActiveX object itself doesn't support it.
  • Val P

    No, the ActiveX object doesn't support onclick events, so the only solution would be to layer something over it, which I don't think is really doable. I had pretty much resigned myself to finding some kind of workaround until I stumbled across the g:background situation. It was more of an oddity than a potential solution, and I was just looking for some logic behind it.

    Aside from that, does anyone know of any good ways to capture mouse events over ActiveX controls

  • GiampaoloSanRemo

    I have been able to use onclick= in the HTML of the g elements without any problems. I can also define gelement.onmousedown = in the JavaScript and it works fine as well, so it seems like they pick up the events without any issues. My real problem is getting the <object> tag to pick them up.

    In thinking about this more, it appears that I'm suffering the same problem many others have had with how the Sidebar handles transparency. That is, I am getting the exact same behavior as someone who is trying to capture mouse events over the transparent parts of backgrounds. You can left click and drag, you can right click and get the context menu, but you can't capture any mouse events in the code. This makes some sense to me if I think of it as the gbackground element layering over my <object> but making itself transparent wherever the overlap occurs.



  • Mike Barry

    None of the g: elements support firing events.

    I presume onmousemove/onmousedown/onmouseup events still fire, you could try tracking the mouse with them, but you'd need to manually check for the mouse being over the elements. I've not tried it, so it may not work.

    In theory your code would be:

    document.onmousemove = mouseXY;
    document.onmousedown = mouseClick;
    document.onmouseup = mouseRelease;

    ...

    function mouseXY() {
    var x = event.clientX;
    var y = event.clientY;
    }

    function mouseClick() {
    var buttonClick = event.button;
    switch(buttonClick)
    {
    case 1: \\left click
    break;

    case 2: \\right click
    break;

    case 4: \\middle click
    break;
    }
    }

  • z-index with <object> and <g:background>