Wt examples  4.2.2
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(cpp14::make_unique<WImage>(url));
22  WImage *dragImage = p->addWidget(cpp14::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 }
Wt::WInteractWidget::setDraggable
void setDraggable(const std::string &mimeType, WWidget *dragWidget=nullptr, bool isDragWidgetOnly=false, WObject *sourceWidget=nullptr)
Wt::WImage
Wt::WContainerWidget::addWidget
virtual void addWidget(std::unique_ptr< WWidget > widget)
Wt::WWebWidget::setMargin
virtual void setMargin(const WLength &margin, WFlags< Side > sides=AllSides) override

Generated on Fri Mar 20 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.17