Wt examples  4.10.4
Functions
DragExample.C File Reference
#include "DragExample.h"
#include "Character.h"
#include <Wt/WEnvironment.h>
#include <Wt/WImage.h>
#include <Wt/WApplication.h>

Go to the source code of this file.

Functions

WImagecreateDragImage (const char *url, const char *smallurl, const char *mimeType, WContainerWidget *p)
 Create an image which can be dragged. More...
 

Function Documentation

◆ createDragImage()

WImage* createDragImage ( const char *  url,
const char *  smallurl,
const char *  mimeType,
WContainerWidget p 
)

Create an image which can be dragged.

The image to be displayed when dragging is given by smallurl, and configured with the given mime type

Definition at line 17 of file DragExample.C.

20 {
21  WImage *result = p->addWidget(std::make_unique<WImage>(url));
22  WImage *dragImage = p->addWidget(std::make_unique<WImage>(smallurl));
23  dragImage->setMargin(-15, Side::Left | Side::Top);
24 
25  /*
26  * Set the image to be draggable, showing the other image (dragImage)
27  * to be used as the widget that is visually dragged.
28  */
29  result->setDraggable(mimeType, dragImage, true);
30 
31  return result;
32 }
virtual void addWidget(std::unique_ptr< WWidget > widget)
void setDraggable(const std::string &mimeType, WWidget *dragWidget=nullptr, bool isDragWidgetOnly=false, WObject *sourceWidget=nullptr)
virtual void setMargin(const WLength &margin, WFlags< Side > sides=AllSides) override