Drag-and-Drop Effects"

From Documentation
m
Line 4: Line 4:
  
 
= Per-Widget Customization =
 
= Per-Widget Customization =
 +
 +
<javadoc directory="jsdoc">zk.Widget</javadoc> has a set of methods for handling drag-and-drop. You could customize them based on your requirement.
 +
 +
If you want to customize a particular widget, you could do as follows<ref><javadoc method="override(java.lang.Object, _global_.Map, _global_.Map)" directory="jsdoc">_global_.zk</javadoc> is a utility to simplify the overriding of a method.</ref>.
 +
 +
<source lang="javascript">
 +
var superwgt = {};
 +
zk.override(wgt, superwgt, {
 +
    initDrag_: function () {
 +
        //your implementation
 +
        superwgt.initDrag_.apply(this, arguments); //if you want to call back the default implementation
 +
    }
 +
});
 +
</source>
 +
 +
If you want to override all widgets of particular class, say, Combobox, you could do as follows.
 +
 +
<source lang="javascript">
 +
var supercomobox = {};
 +
zk.override(zul.inp.Combobox.prototype, supercomobox, {
 +
    initDrag_: function () {
 +
        //your implementation
 +
        supercomobox.initDrag_.apply(this, arguments); //if you want to call back the default implementation
 +
    }
 +
});
 +
</source>
 +
 +
If you override <javadoc directory="jsdoc">zk.Widget</javadoc>, then all widgets are affected.
 +
 +
<blockquote>
 +
----
 +
<references/>
 +
</blockquote>
  
 
= Browser-level Customization =
 
= Browser-level Customization =

Revision as of 02:14, 22 December 2010


Drag-and-Drop Effects



There are two levels to customize the drag-and-drop effects: per-widget and browser-level.

Per-Widget Customization

Widget has a set of methods for handling drag-and-drop. You could customize them based on your requirement.

If you want to customize a particular widget, you could do as follows[1].

var superwgt = {};
zk.override(wgt, superwgt, {
    initDrag_: function () {
        //your implementation
        superwgt.initDrag_.apply(this, arguments); //if you want to call back the default implementation
    }
});

If you want to override all widgets of particular class, say, Combobox, you could do as follows.

var supercomobox = {};
zk.override(zul.inp.Combobox.prototype, supercomobox, {
    initDrag_: function () {
        //your implementation
        supercomobox.initDrag_.apply(this, arguments); //if you want to call back the default implementation
    }
});

If you override Widget, then all widgets are affected.


  1. zk.override(Object, Map, Map) is a utility to simplify the overriding of a method.

Browser-level Customization

DnD provides a collection of drag-and-drop utilities. By customizing it, all widgets in the same browser will be affected.

For example, if you would like customize ghosting" of the DOM element being dragged, you could override DnD.ghost(Draggable, Offset, String) as follows.

var superghost = zk.DnD.ghost;
zk.DnD.ghost = function (drag, ofs, msg) {
    if (msg != null)
        return superghost(drag, ofs, msg);
   //do whatever you want
}

Version History

Last Update : 2010/12/22


Version Date Content
     



Last Update : 2010/12/22

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.