Thread: Drag and Drop
View Single Post
  #1  
Old 08-03-2008, 05:44 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Drag and Drop

For Valikorlia's trading GUI, I'm wanting to implement dragging and dropping. So far, I've gotten dragging down. However, I can't seem to figure out dropping. The "3" is arbitrary; I just copied another NAT's method (which obviously isn't working in this case ).

This is how I'm doing it. First, we have onRecordSelection(obj), which is just obj.onSelect(). This triggers onDragIcon(obj). (I do it this way to prevent a different icon from being selected when dragging the mouse over it.) From there, a GuiShowImgCtrl is created, which is the floating icon that the user's dragging around. The problem I'm having is detecting when the mouse is over TradeOfferScroll.
PHP Code:
function onDragIcon(obj) {
  if(
this.dragging) {
    return;
  }
  new 
GuiShowImgCtrl("TradeInventoryFloater") {
    
this.width 32;
    
this.height 32;
    
System.parseimage(thisstaticdata.tradeitems[(@ obj).itemid].icon);
    
this.mousescreenx;
    
this.mousescreeny;
  }
  
setTimer(0.05);

PHP Code:
function onTimeout() {
  if(
leftmousebuttonglobal) {
    
with(TradeInventoryFloater) {
      
this.mousescreenx;
      
this.mousescreeny;
    }
    
this.dragging true;
    
setTimer(0.05);
  }
  else {
    if(
mousescreenx in  |TradeOfferScroll.xTradeOfferScroll.3|) {
      if(
mousescreeny in |TradeOfferScroll.yTradeOfferScroll.3|) {
        echo(
"Added to offer");
      }
    }
    else {
      echo(
"Destroyed");
    }
    
this.dragging false;
    
System.destroyobject("TradeInventoryFloater");
    
setTimer(0);
  }

Another NAT on Valikorlia suggested using showimg() instead of a GuiShowImgCtrl. Is there any benefit with doing this, as opposed to using a GUI control?
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote