The Official Milescript Forums Forum Index
  Username:   Password:   
   
   http://milescript.org
Home  FAQ  Search  Memberlist  Usergroups  Profile  Register
 Log in to check your private messages
Welcome
Welcome to The Official Milescript Forums.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

ExtWrap
Goto page Previous  1, 2
 
Post new topic   Reply to topic    The Official Milescript Forums Forum Index -> Q & A
View previous topic :: View next topic  
Author Message
gregyouree



Joined: 10 Oct 2007
Posts: 13
Location: Atlanta

PostPosted: Sun Jan 20, 2008 6:53 pm    Post subject: Ext Listeners Reply with quote

I use some of the Drag and Drop listeners in the PortalDropZone, http://milescript.org/portaldemosource/PortalDropZone.html, class.

Code:
DropTargetConfig targetConfig = new DropTargetConfig{
   ddScrollConfig: ddscroll,
   notifyOver: notifyOver,
   notifyOut: notifyOut,
   notifyDrop: notifyDrop
};

target = new DropTarget(panel.body.dom, targetConfig);


And here is the definition of the above methods from the same class.

Code:
private String notifyOver(DragSource dd, EventObject e, Object data) {
      Array<int> xy = e.getXY();
      PanelProxy px = (PanelProxy)dd.getProxy();
      
      // case column widths
      if(this.grid == null) {
         this.grid = this.getGrid();
      }
      
      // handle case scroll where scrollbars appear during drag
      int cw = panel.body.dom.clientWidth;
      if(this.lastCW == null) {
         this.lastCW = cw;
      } else if(this.lastCW != cw) {
         this.lastCW = cw;
         panel.doLayout();
         this.grid = this.getGrid();
      }
      
      // determine column
      int col = 0;
      Array<PortalBox> xs = this.grid.columnX;
      boolean cmatch = false;
      for(int len = xs.length; len > col; col++) {
         if(xy[0] < (xs[col].x + xs[col].w)) {
            cmatch = true;
            break;
         }
      }
            
      // no match fix last index
      if(!cmatch) {
         col--;
      }
      
      // find insertion position
      Component p = null;
      boolean match = false;
      int pos = 0;
      Container c = (Container)panel.items.itemAt(col);
      Array<Component> items = c.items.items;
      
      for(int len = items.length; len > pos; pos++) {
         p = items[pos];
         int h = p.getEl().getHeight();
         int temp = (p.getEl().getY()+(h/2));
         if(h !== 0 && temp > xy[1]) {
            match = true;
            break;
         }
      }
      
      int posVal = pos;
      if(!match || p == null) {
         posVal = c.items.getCount();
      }
      
      PortalEvent overEvent = new PortalEvent(panel, dd, e, data, col, c, posVal, target.dropAllowed);
      
      if(panel.fireEvent("validatedrop", overEvent) !== false &&
         panel.fireEvent("beforedragover", overEvent) !== false) {
         
         // make sure proxy width is fluid
         px.getProxy().setWidth("auto");
         
         if(p != null) {
            if(match) {
               px.moveProxy(p.getEl().dom.parentNode, p.getEl().dom);
            } else {
               px.moveProxy(p.getEl().dom.parentNode, null);
            }
         } else {
            px.moveProxy(c.getEl().dom, null);
         }
         
         if(!match || p == null) {
            this.lastPos = new PortalPos(c, col, null);
         } else {
            this.lastPos = new PortalPos(c, col, pos);
         }
         this.scrollPos = panel.body.getScroll();
         return overEvent.status;
      } else {
         return overEvent.status;
      }
   }
   
   private void notifyOut() {
      this.grid = null;
   }
   
   private void notifyDrop(DragSource dd, EventObject e, Object data) {
      this.grid = null;
      
      PanelProxy px = (PanelProxy)dd.getProxy();
      
      Container c = this.lastPos.c;
      int col = this.lastPos.col;
      int pos = c.items.getCount();
      if(this.lastPos.p != null) {
         pos = this.lastPos.p;
      }
      
      PortalEvent dropEvent = new PortalEvent(panel, dd, e, data, col, c, pos, target.dropAllowed);
      
      if(this.panel.fireEvent('validatedrop', dropEvent) !== false &&
         this.panel.fireEvent('beforedrop', dropEvent) !== false) {
         
         if(px.getEl() != null) {
            px.getEl().remove();
            px.panel.getEl().dom.parentNode.removeChild(px.panel.getEl().dom);
         }
         
         if(pos !== null){
                c.insert(pos, px.panel);
            }else{
                c.add(px.panel);
            }
         
         c.doLayout();
         
         panel.fireEvent('drop', dropEvent);
         
         // scroll position is lost on drop, fix it
            this.st = this.scrollPos.top;
            if(st != null){
                window.setTimeout(timeoutFunc, 10);
            }
      }
   }


I believe this is what you're talking about but I could be wrong.
_________________
--
Greg Youree
Co-founder
Point5u, LLC
Back to top
View user's profile Send private message Visit poster's website
krycek



Joined: 17 Jan 2008
Posts: 10

PostPosted: Sun Jan 20, 2008 8:21 pm    Post subject: Reply with quote

I mean like: element.on ("EVENT", function, scope);

Tomorrow I'll take a closer look!

Thank you for your help!
Back to top
View user's profile Send private message
gregyouree



Joined: 10 Oct 2007
Posts: 13
Location: Atlanta

PostPosted: Sun Jan 20, 2008 8:30 pm    Post subject: Ext Listeners Reply with quote

Ah I see. That should work fine. You can pass a Function as a reference in Milescript. We recommend wrapping them in Delegates for clarity but it is not always necessary. I just pass the Functions directly a lot of the time, especially to external classes.

Glad to help out, let us know how it goes.
_________________
--
Greg Youree
Co-founder
Point5u, LLC
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    The Official Milescript Forums Forum Index -> Q & A All times are GMT - 5 Hours
Goto page Previous  1, 2
Page 2 of 2   

 
Jump to:    
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Community Chest


phpBB skin developed by: John Olson
Powered by phpBB
Hosted by FreeForums.org