Display Drag Icon in drag and drop : Drag Drop : GUI Components : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  GUI Components   » [  Drag Drop  ]   
 



Display Drag Icon in drag and drop

Please note that some example is only working under IE or Firefox.


<html>
<head>
<title>DynAPI Examples - Drag Icon</title>
<script language="JavaScript" src="./dynapisrc/dynapi.js"></script>
<script language="Javascript">
dynapi.library.setPath('./dynapisrc/');
dynapi.library.include('dynapi.api');
dynapi.library.include('DragEvent');
</script>
<script language="Javascript">

var icon = new DynLayer('<img src="./dynapiexamples/images/file.gif">',0,0,20,24);
icon.setMaximumSize(20,24);

dynapi.functions.getImage("./dynapiexamples/images/menu_side.gif");
var icon2 = new DynLayer(null,0,0,0,0,null,'./dynapiexamples/images/menu_side.gif');


// layer 1
var lyr = new DynLayer('Yellow Source',50,100,100,100,'yellow');
lyr.setDragIcon(icon);
lyr.setDragEnabled(true,null,true);
dynapi.document.addChild(lyr);
lyr._tag='yellow';

// layer 2
var lyr = new DynLayer('Lime Source',50,210,100,100,'lime');
lyr.setDragIcon(icon);
lyr.setDragEnabled(true,null,true);
dynapi.document.addChild(lyr,'layer2');
lyr._tag='lime';

// target
var lyr = new DynLayer('Target',250,100,300,210,'gold');
dynapi.document.addChild(lyr,'target');
lyr.addEventListener({
  ondrop:function(e,dragIcon){
    o = dragIcon.getDragSource();
    alert("You've dropped the "+o._tag+" layer");
  }
});

function changeIcon(){
  dynapi.document.layer2.setDragIcon(icon2);
}
</script>
</head>

<body>
Drag and Drop the Yellow or Lime colored layers onto the Gold layer <br><br>
<a href="javascript:;" onclick="changeIcon()">Change Lime Source Drag Icon<a>
</body>
</html>

           
       
Download: dynapi.zip   ( 791  K )  
Related examples in the same category
1.  DynAPI Examples - Drag Drop /w Collision DetectionHas Download File
2.  Drag Over Event: Drag and Drop the file over recycle binsHas Download File
3.  Yahoo! UI Library - Drag and Drop 1Has Download File
4.  Yahoo! UI Library - Drag and Drop 2Has Download File
5.  Yahoo! UI Library - Drag and Drop 3Has Download File
6.  Yahoo! UI Library - Drag and Drop 5Has Download File
7.  Dragged object is on topHas Download File
8.  Drag and Drop - DDProxyHas Download File
9.  Yahoo! UI Library - Drag and Drop: ResizeHas Download File
10.  Drag and Drop: Multiple groups, targetable affordanceHas Download File
11.  Drag and Drop to sort slidesHas Download File
12.  Drag and Drop to sort listsHas Download File
13.  Drag inside and outside a rangeHas Download File
14.  Drag stillHas Download File
15.  Crop an imageHas Download File
16.  Drag and drop custom window with title bar
17.  Dragable float window with scrollable text inside
18.  Dragable transparent window
19.  Drag within a range 2
20.  Dragable sorted listHas Download File
21.  Dragable and sortable toolbarHas Download File
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.