com.extjs.gxt.ui.client.fx
Class Draggable

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.fx.Draggable
All Implemented Interfaces:
com.extjs.gxt.ui.client.event.Observable

public class Draggable
extends com.extjs.gxt.ui.client.event.BaseObservable

Adds drag behavior to any widget. Drag operations can be initiated from the widget itself, or another widget, such as the header in a dialog.

It is possible to specify event targets that will be ignored. If the target element has a 'x-nodrag' style it will not trigger a drag operation.

Events:
DragStart : DragEvent(draggable, component, event)
Fires after a drag has started.
DragMove : DragEvent(draggable, component, event)
Fires after the mouse moves.
  • draggable : this
  • component : drag component
  • event : the dom event
  • DragCancel : DragEvent(draggable, component, event)
    Fires after a drag has been cancelled.
    DragEnd : DragEvent(draggable, component, event)
    Fires after a drag has ended.


    Field Summary
    protected  int conHeight
               
    protected  int conWidth
               
    protected  int conX
               
    protected  int conY
               
    protected  int dragStartX
               
    protected  int dragStartY
               
    protected  int lastX
               
    protected  int lastY
               
    protected  El proxyEl
               
    protected  com.extjs.gxt.ui.client.util.Rectangle startBounds
               
     
    Constructor Summary
    Draggable(com.extjs.gxt.ui.client.widget.Component dragComponent)
              Creates a new draggable instance.
    Draggable(com.extjs.gxt.ui.client.widget.Component dragComponent, com.extjs.gxt.ui.client.widget.Component handle)
              Create a new draggable instance.
     
    Method Summary
     void addDragListener(com.extjs.gxt.ui.client.event.DragListener listener)
              Adds a listener to receive drag events.
    protected  void afterDrag()
               
     void cancelDrag()
              Cancels the drag if running.
    protected  El createProxy()
               
     com.extjs.gxt.ui.client.widget.Component getContainer()
              Returns the drag container.
     com.extjs.gxt.ui.client.widget.Component getDragHandle()
              Returns the drag handle.
     com.extjs.gxt.ui.client.widget.Component getDragWidget()
              Returns the widget being dragged.
     java.lang.String getProxyStyle()
              Returns the proxy style.
     int getStartDragDistance()
              Returns the number of pixels the cursor must move before dragging begins.
     boolean isConstrainClient()
              Returns true if drag is constrained to the viewport.
     boolean isConstrainHorizontal()
              Returns true if horizontal movement is constrained.
     boolean isConstrainVertical()
              Returns true if vertical movement is constrained.
     boolean isDragging()
              Returns true if a drag is in progress.
     boolean isEnabled()
              Returns true if enabled.
     boolean isMoveAfterProxyDrag()
              Returns true if the drag widget is moved after a proxy drag.
     boolean isSizeProxyToSource()
              Returns true if the proxy element is sized to match the drag widget.
     boolean isUpdateZIndex()
              Returns true if the z-index is updated after a drag.
     boolean isUseProxy()
              Returns true if proxy element is enabled.
    protected  void onMouseDown(com.extjs.gxt.ui.client.event.ComponentEvent ce)
               
    protected  void onMouseMove(com.google.gwt.user.client.Event event)
               
     void release()
              Removes the drag handles.
     void removeDragListener(com.extjs.gxt.ui.client.event.DragListener listener)
              Removes a previously added listener.
     void setConstrainClient(boolean constrainClient)
              True to set constrain movement to the viewport (defaults to true).
     void setConstrainHorizontal(boolean constrainHorizontal)
              True to stop horizontal movement (defaults to false).
     void setConstrainVertical(boolean constrainVertical)
              True to stop vertical movement (defaults to false).
     void setContainer(com.extjs.gxt.ui.client.widget.Component container)
              Specifies a container to which the drag widget is constrained.
     void setEnabled(boolean enabled)
              Enables dragging if the argument is true, and disables it otherwise.
     void setMoveAfterProxyDrag(boolean moveAfterProxyDrag)
              True to move source widget after a proxy drag (defaults to true).
     void setProxy(El element)
              Sets the proxy element.
     void setProxyStyle(java.lang.String proxyStyle)
              Sets the style name used for proxy drags (defaults to 'my-drag-proxy').
     void setSizeProxyToSource(boolean sizeProxyToSource)
              True to set proxy dimensions the same as the drag widget (defaults to true).
     void setStartDragDistance(int startDragDistance)
              Specifies how far the cursor must move after mousedown to start dragging (defaults to 2).
     void setUpdateZIndex(boolean updateZIndex)
              True if the CSS z-index should be updated on the widget being dragged.
     void setUseProxy(boolean useProxy)
              True to use a proxy widget during drag operation (defaults to true).
     void setXConstraint(int left, int right)
              Constrains the horizontal travel.
     void setYConstraint(int top, int bottom)
              Constrains the vertical travel.
    protected  void startDrag(com.google.gwt.user.client.Event event)
               
    protected  void stopDrag(com.google.gwt.user.client.Event event)
               
     
    Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
    addListener, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    conX

    protected int conX

    conY

    protected int conY

    conWidth

    protected int conWidth

    conHeight

    protected int conHeight

    dragStartX

    protected int dragStartX

    dragStartY

    protected int dragStartY

    lastX

    protected int lastX

    lastY

    protected int lastY

    startBounds

    protected com.extjs.gxt.ui.client.util.Rectangle startBounds

    proxyEl

    protected El proxyEl
    Constructor Detail

    Draggable

    public Draggable(com.extjs.gxt.ui.client.widget.Component dragComponent)
    Creates a new draggable instance.

    Parameters:
    dragComponent - the component to be dragged

    Draggable

    public Draggable(com.extjs.gxt.ui.client.widget.Component dragComponent,
                     com.extjs.gxt.ui.client.widget.Component handle)
    Create a new draggable instance.

    Parameters:
    dragComponent - the component to be dragged
    handle - the component drags will be initiated from
    Method Detail

    addDragListener

    public void addDragListener(com.extjs.gxt.ui.client.event.DragListener listener)
    Adds a listener to receive drag events.

    Parameters:
    listener - the drag listener to be added

    cancelDrag

    public void cancelDrag()
    Cancels the drag if running.


    getContainer

    public com.extjs.gxt.ui.client.widget.Component getContainer()
    Returns the drag container.

    Returns:
    the drag container

    getDragHandle

    public com.extjs.gxt.ui.client.widget.Component getDragHandle()
    Returns the drag handle.

    Returns:
    the drag handle

    getDragWidget

    public com.extjs.gxt.ui.client.widget.Component getDragWidget()
    Returns the widget being dragged.

    Returns:
    the drag widget

    getProxyStyle

    public java.lang.String getProxyStyle()
    Returns the proxy style.

    Returns:
    the proxy style

    getStartDragDistance

    public int getStartDragDistance()
    Returns the number of pixels the cursor must move before dragging begins.

    Returns:
    the distance in pixels

    isConstrainClient

    public boolean isConstrainClient()
    Returns true if drag is constrained to the viewport.

    Returns:
    the constrain client state

    isConstrainHorizontal

    public boolean isConstrainHorizontal()
    Returns true if horizontal movement is constrained.

    Returns:
    the horizontal constrain state

    isConstrainVertical

    public boolean isConstrainVertical()
    Returns true if vertical movement is constrained.

    Returns:
    true if vertical movement is constrained

    isDragging

    public boolean isDragging()
    Returns true if a drag is in progress.

    Returns:
    the drag state

    isEnabled

    public boolean isEnabled()
    Returns true if enabled.

    Returns:
    the enable state

    isMoveAfterProxyDrag

    public boolean isMoveAfterProxyDrag()
    Returns true if the drag widget is moved after a proxy drag.

    Returns:
    the move after proxy state

    isSizeProxyToSource

    public boolean isSizeProxyToSource()
    Returns true if the proxy element is sized to match the drag widget.

    Returns:
    the size proxy to source state

    isUpdateZIndex

    public boolean isUpdateZIndex()
    Returns true if the z-index is updated after a drag.

    Returns:
    the update z-index state

    isUseProxy

    public boolean isUseProxy()
    Returns true if proxy element is enabled.

    Returns:
    the use proxy state

    release

    public void release()
    Removes the drag handles.


    removeDragListener

    public void removeDragListener(com.extjs.gxt.ui.client.event.DragListener listener)
    Removes a previously added listener.

    Parameters:
    listener - the listener to be removed

    setConstrainClient

    public void setConstrainClient(boolean constrainClient)
    True to set constrain movement to the viewport (defaults to true).

    Parameters:
    constrainClient - true to constrain to viewport

    setConstrainHorizontal

    public void setConstrainHorizontal(boolean constrainHorizontal)
    True to stop horizontal movement (defaults to false).

    Parameters:
    constrainHorizontal - true to stop horizontal movement

    setConstrainVertical

    public void setConstrainVertical(boolean constrainVertical)
    True to stop vertical movement (defaults to false).

    Parameters:
    constrainVertical - true to stop vertical movement

    setContainer

    public void setContainer(com.extjs.gxt.ui.client.widget.Component container)
    Specifies a container to which the drag widget is constrained.

    Parameters:
    container - the container

    setEnabled

    public void setEnabled(boolean enabled)
    Enables dragging if the argument is true, and disables it otherwise.

    Parameters:
    enabled - the new enabled state

    setMoveAfterProxyDrag

    public void setMoveAfterProxyDrag(boolean moveAfterProxyDrag)
    True to move source widget after a proxy drag (defaults to true).

    Parameters:
    moveAfterProxyDrag - true to move after a proxy drag

    setProxy

    public void setProxy(El element)
    Sets the proxy element.

    Parameters:
    element - the proxy element

    setProxyStyle

    public void setProxyStyle(java.lang.String proxyStyle)
    Sets the style name used for proxy drags (defaults to 'my-drag-proxy').

    Parameters:
    proxyStyle - the proxy style

    setSizeProxyToSource

    public void setSizeProxyToSource(boolean sizeProxyToSource)
    True to set proxy dimensions the same as the drag widget (defaults to true).

    Parameters:
    sizeProxyToSource - true to update proxy size

    setStartDragDistance

    public void setStartDragDistance(int startDragDistance)
    Specifies how far the cursor must move after mousedown to start dragging (defaults to 2).

    Parameters:
    startDragDistance - the start distance in pixels

    setUpdateZIndex

    public void setUpdateZIndex(boolean updateZIndex)
    True if the CSS z-index should be updated on the widget being dragged. Setting this value to true will ensure that the dragged element is always displayed over all other widgets (defaults to true).

    Parameters:
    updateZIndex - true update the z-index

    setUseProxy

    public void setUseProxy(boolean useProxy)
    True to use a proxy widget during drag operation (defaults to true).

    Parameters:
    useProxy - true use a proxy

    setXConstraint

    public void setXConstraint(int left,
                               int right)
    Constrains the horizontal travel.

    Parameters:
    left - the number of pixels the element can move to the left
    right - the number of pixels the element can move to the right

    setYConstraint

    public void setYConstraint(int top,
                               int bottom)
    Constrains the vertical travel.

    Parameters:
    top - the number of pixels the element can move to the up
    bottom - the number of pixels the element can move to the down

    afterDrag

    protected void afterDrag()

    createProxy

    protected El createProxy()

    onMouseDown

    protected void onMouseDown(com.extjs.gxt.ui.client.event.ComponentEvent ce)

    onMouseMove

    protected void onMouseMove(com.google.gwt.user.client.Event event)

    startDrag

    protected void startDrag(com.google.gwt.user.client.Event event)

    stopDrag

    protected void stopDrag(com.google.gwt.user.client.Event event)


    Copyright © 2010. All Rights Reserved.