Package com.sencha.gxt.fx.client
Class Draggable
- java.lang.Object
-
- com.sencha.gxt.fx.client.Draggable
-
- All Implemented Interfaces:
DragCancelEvent.HasDragCancelHandlers,DragEndEvent.HasDragEndHandlers,DragHandler.HasDragHandlers,DragMoveEvent.HasDragMoveHandlers,DragStartEvent.HasDragStartHandlers
public class Draggable extends Object implements DragStartEvent.HasDragStartHandlers, DragEndEvent.HasDragEndHandlers, DragMoveEvent.HasDragMoveHandlers, DragCancelEvent.HasDragCancelHandlers, DragHandler.HasDragHandlers
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 the
CommonStyles.Styles.nodrag()style (as returned byCommonStyles.get()) it will not trigger a drag operation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDraggable.DraggableAppearance
-
Constructor Summary
Constructors Constructor Description Draggable(com.google.gwt.user.client.ui.Widget dragWidget)Creates a new draggable instance.Draggable(com.google.gwt.user.client.ui.Widget dragWidget, com.google.gwt.user.client.ui.Widget handleWidget)Create a new draggable instance.Draggable(com.google.gwt.user.client.ui.Widget dragWidget, com.google.gwt.user.client.ui.Widget handleWidget, Draggable.DraggableAppearance appearance)Create a new draggable instance.Draggable(com.google.gwt.user.client.ui.Widget dragWidget, Draggable.DraggableAppearance appearance)Creates a new draggable instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistrationaddDragCancelHandler(DragCancelEvent.DragCancelHandler handler)Adds aDragCancelEvent.DragCancelHandlerhandler forDragCancelEventevents.com.google.gwt.event.shared.HandlerRegistrationaddDragEndHandler(DragEndEvent.DragEndHandler handler)Adds aDragEndEvent.DragEndHandlerhandler forDragEndEventevents.com.google.gwt.event.shared.HandlerRegistrationaddDragHandler(DragHandler handler)Adds aDragHandlerhandler forDragStartEvent,DragEndEvent,DragCancelEvent,DragMoveEventevents.com.google.gwt.event.shared.HandlerRegistrationaddDragMoveHandler(DragMoveEvent.DragMoveHandler handler)Adds aDragMoveEvent.DragMoveHandlerhandler forDragMoveEventevents.com.google.gwt.event.shared.HandlerRegistrationaddDragStartHandler(DragStartEvent.DragStartHandler handler)Adds aDragStartEvent.DragStartHandlerhandler forDragStartEventevents.voidcancelDrag()Cancels the drag if running.com.google.gwt.user.client.ui.WidgetgetContainer()Returns the drag container.com.google.gwt.user.client.ui.WidgetgetDragHandle()Returns the drag handleWidget.com.google.gwt.user.client.ui.WidgetgetDragWidget()Returns the widget being dragged.intgetStartDragDistance()Returns the number of pixels the cursor must move before dragging begins.booleanisConstrainClient()Returns true if drag is constrained to the viewport.booleanisConstrainHorizontal()Returns true if horizontal movement is constrained.booleanisConstrainVertical()Returns true if vertical movement is constrained.booleanisDragging()Returns true if a drag is in progress.booleanisEnabled()Returns true if enabled.booleanisMoveAfterProxyDrag()Returns true if the drag widget is moved after a proxy drag.booleanisSizeProxyToSource()Returns true if the proxy element is sized to match the drag widget.booleanisUpdateZIndex()Returns true if the z-index is updated after a drag.booleanisUseProxy()Returns true if proxy element is enabled.voidrelease()Removes the drag handles.voidsetConstrainClient(boolean constrainClient)True to set constrain movement to the viewport (defaults to true).voidsetConstrainHorizontal(boolean constrainHorizontal)True to stop horizontal movement (defaults to false).voidsetConstrainVertical(boolean constrainVertical)True to stop vertical movement (defaults to false).voidsetContainer(com.google.gwt.user.client.ui.Widget container)Specifies a container to which the drag widget is constrained.voidsetEnabled(boolean enabled)Enables dragging if the argument is true, and disables it otherwise.voidsetMoveAfterProxyDrag(boolean moveAfterProxyDrag)True to move source widget after a proxy drag (defaults to true).voidsetProxy(XElement element)Sets the proxy element.voidsetProxyStyle(String proxyClass)voidsetSizeProxyToSource(boolean sizeProxyToSource)True to set proxy dimensions the same as the drag widget (defaults to true).voidsetStartDragDistance(int startDragDistance)Specifies how far the cursor must move after mousedown to start dragging (defaults to 2).voidsetUpdateZIndex(boolean updateZIndex)True if the CSS z-index should be updated on the widget being dragged.voidsetUseProxy(boolean useProxy)True to use a proxy widget during drag operation (defaults to true).voidsetXConstraint(int left, int right)Constrains the horizontal travel.voidsetYConstraint(int top, int bottom)Constrains the vertical travel.
-
-
-
Constructor Detail
-
Draggable
public Draggable(com.google.gwt.user.client.ui.Widget dragWidget)
Creates a new draggable instance.- Parameters:
dragWidget- the widget to be dragged
-
Draggable
public Draggable(com.google.gwt.user.client.ui.Widget dragWidget, Draggable.DraggableAppearance appearance)Creates a new draggable instance.- Parameters:
dragWidget- the widget to be draggedappearance- the appearance with which to render the component
-
Draggable
public Draggable(com.google.gwt.user.client.ui.Widget dragWidget, com.google.gwt.user.client.ui.Widget handleWidget)Create a new draggable instance.- Parameters:
dragWidget- the widget to be draggedhandleWidget- the widget drags will be initiated from
-
Draggable
public Draggable(com.google.gwt.user.client.ui.Widget dragWidget, com.google.gwt.user.client.ui.Widget handleWidget, Draggable.DraggableAppearance appearance)Create a new draggable instance.- Parameters:
dragWidget- the widget to be draggedhandleWidget- the widget drags will be initiated fromappearance- the appearance with which to render the component
-
-
Method Detail
-
addDragCancelHandler
public com.google.gwt.event.shared.HandlerRegistration addDragCancelHandler(DragCancelEvent.DragCancelHandler handler)
Description copied from interface:DragCancelEvent.HasDragCancelHandlersAdds aDragCancelEvent.DragCancelHandlerhandler forDragCancelEventevents.- Specified by:
addDragCancelHandlerin interfaceDragCancelEvent.HasDragCancelHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addDragEndHandler
public com.google.gwt.event.shared.HandlerRegistration addDragEndHandler(DragEndEvent.DragEndHandler handler)
Description copied from interface:DragEndEvent.HasDragEndHandlersAdds aDragEndEvent.DragEndHandlerhandler forDragEndEventevents.- Specified by:
addDragEndHandlerin interfaceDragEndEvent.HasDragEndHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addDragHandler
public com.google.gwt.event.shared.HandlerRegistration addDragHandler(DragHandler handler)
Description copied from interface:DragHandler.HasDragHandlersAdds aDragHandlerhandler forDragStartEvent,DragEndEvent,DragCancelEvent,DragMoveEventevents.- Specified by:
addDragHandlerin interfaceDragHandler.HasDragHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addDragMoveHandler
public com.google.gwt.event.shared.HandlerRegistration addDragMoveHandler(DragMoveEvent.DragMoveHandler handler)
Description copied from interface:DragMoveEvent.HasDragMoveHandlersAdds aDragMoveEvent.DragMoveHandlerhandler forDragMoveEventevents.- Specified by:
addDragMoveHandlerin interfaceDragMoveEvent.HasDragMoveHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addDragStartHandler
public com.google.gwt.event.shared.HandlerRegistration addDragStartHandler(DragStartEvent.DragStartHandler handler)
Description copied from interface:DragStartEvent.HasDragStartHandlersAdds aDragStartEvent.DragStartHandlerhandler forDragStartEventevents.- Specified by:
addDragStartHandlerin interfaceDragStartEvent.HasDragStartHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
cancelDrag
public void cancelDrag()
Cancels the drag if running.
-
getContainer
public com.google.gwt.user.client.ui.Widget getContainer()
Returns the drag container.- Returns:
- the drag container
-
setContainer
public void setContainer(com.google.gwt.user.client.ui.Widget container)
Specifies a container to which the drag widget is constrained.- Parameters:
container- the container
-
getDragHandle
public com.google.gwt.user.client.ui.Widget getDragHandle()
Returns the drag handleWidget.- Returns:
- the drag handleWidget
-
getDragWidget
public com.google.gwt.user.client.ui.Widget getDragWidget()
Returns the widget being dragged.- Returns:
- the drag widget
-
getStartDragDistance
public int getStartDragDistance()
Returns the number of pixels the cursor must move before dragging begins.- Returns:
- the distance in pixels
-
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
-
isConstrainClient
public boolean isConstrainClient()
Returns true if drag is constrained to the viewport.- Returns:
- the constrain client state
-
setConstrainClient
public void setConstrainClient(boolean constrainClient)
True to set constrain movement to the viewport (defaults to true).- Parameters:
constrainClient- true to constrain to viewport
-
isConstrainHorizontal
public boolean isConstrainHorizontal()
Returns true if horizontal movement is constrained.- Returns:
- the horizontal constrain state
-
setConstrainHorizontal
public void setConstrainHorizontal(boolean constrainHorizontal)
True to stop horizontal movement (defaults to false).- Parameters:
constrainHorizontal- true to stop horizontal movement
-
isConstrainVertical
public boolean isConstrainVertical()
Returns true if vertical movement is constrained.- Returns:
- true if vertical movement is constrained
-
setConstrainVertical
public void setConstrainVertical(boolean constrainVertical)
True to stop vertical movement (defaults to false).- Parameters:
constrainVertical- true to stop vertical movement
-
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
-
setEnabled
public void setEnabled(boolean enabled)
Enables dragging if the argument is true, and disables it otherwise.- Parameters:
enabled- the new enabled state
-
isMoveAfterProxyDrag
public boolean isMoveAfterProxyDrag()
Returns true if the drag widget is moved after a proxy drag.- Returns:
- the move after proxy 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
-
isSizeProxyToSource
public boolean isSizeProxyToSource()
Returns true if the proxy element is sized to match the drag widget.- Returns:
- the size proxy to source state
-
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
-
isUpdateZIndex
public boolean isUpdateZIndex()
Returns true if the z-index is updated after a drag.- Returns:
- the update z-index state
-
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
-
isUseProxy
public boolean isUseProxy()
Returns true if proxy element is enabled.- Returns:
- the use proxy state
-
setUseProxy
public void setUseProxy(boolean useProxy)
True to use a proxy widget during drag operation (defaults to true).- Parameters:
useProxy- true use a proxy
-
release
public void release()
Removes the drag handles.
-
setProxy
public void setProxy(XElement element)
Sets the proxy element.- Parameters:
element- the proxy element
-
setProxyStyle
public void setProxyStyle(String proxyClass)
-
setXConstraint
public void setXConstraint(int left, int right)Constrains the horizontal travel.- Parameters:
left- the number of pixels the element can move to the leftright- 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 upbottom- the number of pixels the element can move to the down
-
-