On Wed, 18 Jul 2001, Kasper Schnell wrote:

> I have problem.

> I several draggable layers, and I want the layer that is currently
> being dragged to be on top (highest z-index) and two of its
> childLayers to be visible. Since I can have a situation where maybe
> 100 layers are draggable, I want to give the layers that is not
> being dragged a lower z-index.
> How do I make a reference to these?
> Is there a way to check whether a DynLayer is "active" (a bit like
> onFocus)?
>
> I'm now using the workaround where I check with:
> de=DragEvent.dragevent
> if (de){do something}
> But it is not referring to the layers not being dragged.
> Please help me.
> Yours Kas

I had the same problem come up recently. I found a function in my DynAPI
mail archives, and modified it a little. Here's what I'm using:

  // Original function by Gordan Bobic <[EMAIL PROTECTED]>
  // Modified by Dougal Campbell <[EMAIL PROTECTED]>
  function bringToFront(obj) {
    var o
    var top
    var maxZ = 10
    var minZ = 3
    o = obj.parent.children
    for (var i = 0; i < o.length; i++)
    {
      top = o[i].getZIndex()
      o[i].setZIndex( (top > minZ) ? (top - 1) : minZ )
      if (top > maxZ) maxZ = t
    }
    obj.setZIndex(++top)
    // window.status = 'Set ' + obj + ' to z=' + top
  }

  // Bring guiWindows to front when clicked
  function addFronter(winobj) {
    var myFronter = new EventListener(winobj)
    myFronter.onmousedown=function(e) {
      bringToFront(winobj)
    }

    winobj.addEventListener(myFronter)
  }

The "addFronter()" routine is a convenience function. That way all I have to
do in my main code is "addFronter(myLayer01)" and it creates the
EventListener and adds it to the layer.

The original brintToFront() didn't work right for me, because it didn't care
about how low the zIndexes went, and I already had layers stacked at certain
levels. I added the "minZ" variable and the "++top" in the final setZIndex
call to work around that.

This might be a good candidate for dynapi.ext.layer. Just make it a
little more generic by making minZ and maxZ optional parameters.

-- 
Ernest MacDougal Campbell III, MCP+I, MCSE <[EMAIL PROTECTED]>
http://dougal.gunters.org/        http://spam.gunters.org/
Lumber Cartel Unit #1654 (tinlc): http://come.to/the.lumber.cartel/
This message is guaranteed to be 100% eror frea!


_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to