Loading ...
Sorry, an error occurred while loading the content.

Re: Easy way to disable dragging but not disable being a target?

Expand Messages
  • someguynameddylan
    I was struggling with this exact same issue not too long ago. I don t have the most kosher solution to this and my approach violates heuristics like no other
    Message 1 of 2 , Jul 2 9:41 AM
    • 0 Attachment
      I was struggling with this exact same issue not too long ago.

      I don't have the most kosher solution to this and my approach violates
      heuristics like no other (*gasp*), but I ended up doing the following.

      I have a class that derives from Y.util.DD with a property called
      isDraggable. When isDraggable is set to false, I take the object's
      method pointers and set them to the methods in
      Y.util.DDTarget.prototype. Then when that property is set to true I
      do the reverse.

      //psuedo code, it kinda looks like this but i'm making no guarantees
      var protoToUse = Y.util.DD, funcName;
      if (false === isDraggable){
      protoTouse = Y.util.DDTarget;
      }

      for(funcName in protoToUse ){
      if (Y.util.lang.isFunction(this[funcName]){
      this[funcName] = protoToUse[funcName];
      }
      }

      Best of luck, if you got something better please share.

      -Dylan


      --- In ydn-javascript@yahoogroups.com, "cosmicrealms" <robert@...> wrote:
      >
      > So I have lots of objects that can be dragged around and on to each
      other.
      > So I use YAHOO.util.DD
      >
      > Some times they can be dragged but are not targets.
      > For this I just set isTarget = false
      >
      > Other times they should not be draggable bu be targets.
      > I thought doing .lock() would work, but this prevents them from being
      > targets as well.
      >
      > What is an easy way to have a YAHOO.util.DD be a target, but not be
      > draggable without locking it?
      >
      >
      > (In the mean time I have just changed line 752 in yui dragdrop.js from:
      > if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
      > to
      > if (oDD.isTarget && oDD != dc) {
      > Which causes locked objects to be valid targets)
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.