Class WFileDropWidget
This widget accepts files that are dropped into it. A signal is triggered whenever one or more
files are dropped. The filename, type and size of these files is immediately available through
the WFileDropWidget.File
interface.
The file upload is done sequentially. All files before the getCurrentIndex()
have either finished, failed or have been
cancelled.
The widget has the default style-class 'Wt-filedropzone'. The style-class 'Wt-dropzone-hover' is added when files are hovered over the widget.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A nested class ofWFileDropWidget
representing a file.Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Cancels the upload of a file.drop()
The signal triggers if one or more files are dropped.protected void
Progresses to an Ajax-enabled widget.int
Return the index of the file that is currently being handled.Returns the vector of uploads managed by this widget.boolean
Returns if the widget is highlighted for drags anywhere on the page.boolean
Returns if all drops are forwarded to this widget.The signal triggers when the upload of a file is about to begin.boolean
remove
(WFileDropWidget.File file) Removes the file.void
setAcceptDrops
(boolean enable) When set to false, the widget no longer accepts any files.void
setDropIndicationEnabled
(boolean enable) Highlight widget if a file is dragged anywhere on the page.void
setFilters
(String acceptAttributes) Sets input accept attributes.void
setGlobalDropEnabled
(boolean enable) Allow dropping the files anywhere on the page.void
setHoverStyleClass
(String className) Deprecated.Override the css rule '.Wt-filedropzone.Wt-dropzone-hover' instead.final void
setJavaScriptFilter
(String filterFn) Supply a function to process file data before it is uploaded to the server.final void
setJavaScriptFilter
(String filterFn, long chunksize) Supply a function to process file data before it is uploaded to the server.void
setJavaScriptFilter
(String filterFn, long chunksize, List<String> imports) Supply a function to process file data before it is uploaded to the server.tooLarge()
The signal triggers when a file is too large for upload.uploaded()
The signal is triggered if any file finished uploading.The signal triggers when an upload failed.Methods inherited from class eu.webtoolkit.jwt.WContainerWidget
addWidget, clear, createDomElement, getContentAlignment, getCount, getDomChanges, getIndexOf, getLayout, getPadding, getScrollLeft, getScrollTop, getWidget, insertBefore, insertWidget, isGlobalUnfocussed, isList, isOrderedList, isUnorderedList, iterateChildren, parentResized, remove, removeWidget, scrolled, setContentAlignment, setContentAlignment, setFormData, setGlobalUnfocused, setLayout, setList, setList, setOverflow, setOverflow, setOverflow, setPadding, setPadding, setPadding
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, render, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
Constructor Details
-
WFileDropWidget
Constructor. -
WFileDropWidget
public WFileDropWidget()Constructor.
-
-
Method Details
-
getUploads
Returns the vector of uploads managed by this widget.The files in this vector are handled sequentially by the widget. All
WFileDropWidget.File
objects in this vector have either finished or failed if they are before thegetCurrentIndex()
, depending on the return value ofisUploadFinished()
. The other files are still being handled.Remark: Since version 4.7.0, this method returns a copy of the vector because we changed the internal vector to hold values of type std::unique_ptr.
- See Also:
-
getCurrentIndex
public int getCurrentIndex()Return the index of the file that is currently being handled.If nothing is to be done, this will return the size of the vector returned by
getUploads()
. -
cancelUpload
Cancels the upload of a file.If you cancel a file that is still waiting to be uploaded, it will stay in the
getUploads()
vector, but it will be skipped. -
remove
Removes the file.This can be used to free resources of files that were already uploaded. A file can only be removed if its index in
getUploads()
is before the current index. -
setAcceptDrops
public void setAcceptDrops(boolean enable) When set to false, the widget no longer accepts any files. -
setHoverStyleClass
Deprecated.Override the css rule '.Wt-filedropzone.Wt-dropzone-hover' instead.Set the style class that is applied when a file is hovered over the widget. -
setFilters
Sets input accept attributes.The accept attribute may be specified to provide user agents with a hint of what file types will be accepted. Use html input accept attributes as input. This only affects the popup that is shown when users click on the widget. A user can still drop any file type.
-
setDropIndicationEnabled
public void setDropIndicationEnabled(boolean enable) Highlight widget if a file is dragged anywhere on the page.As soon as a drag enters anywhere on the page the styleclass 'Wt-dropzone-indication' is added to this widget. This can be useful to point the user to the correct place to drop the file. Once the user drags a file over the widget itself, the styleclass 'hover-style' is also added. This can be enabled for multiple dropwidgets if only one of them is visible at the same time.
- See Also:
-
isDropIndicationEnabled
public boolean isDropIndicationEnabled()Returns if the widget is highlighted for drags anywhere on the page.- See Also:
-
setGlobalDropEnabled
public void setGlobalDropEnabled(boolean enable) Allow dropping the files anywhere on the page.If enabled, a drop anywhere on the page will be forwarded to this widget.
- See Also:
-
isGlobalDropEnabled
public boolean isGlobalDropEnabled()Returns if all drops are forwarded to this widget.- See Also:
-
setJavaScriptFilter
Supply a function to process file data before it is uploaded to the server. -
setJavaScriptFilter
Supply a function to process file data before it is uploaded to the server. -
setJavaScriptFilter
Supply a function to process file data before it is uploaded to the server.Calls
setJavaScriptFilter(filterFn, chunksize, new ArrayList
()) -
drop
The signal triggers if one or more files are dropped. -
newUpload
The signal triggers when the upload of a file is about to begin.After this signal is triggered, the upload automatically starts. The upload can still fail if the file is too large or if there is a network error.
-
uploaded
The signal is triggered if any file finished uploading. -
tooLarge
The signal triggers when a file is too large for upload.This signal is triggered when the widget attempts to upload the file.
The second argument is the size of the file in bytes.
-
uploadFailed
The signal triggers when an upload failed.This signal will trigger when the widget skips over one of the files in the list for an unknown reason (e.g. happens when you drop a folder).
-
enableAjax
protected void enableAjax()Description copied from class:WWidget
Progresses to an Ajax-enabled widget.This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.
You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.
- Overrides:
enableAjax
in classWWebWidget
- See Also:
-