void DragContainer::onMouseButtonUp(MouseEventArgs& e) { Window::onMouseButtonUp(e); if (e.button == LeftButton) { if (d_dragging) { // release picked up state if (d_pickedUp) d_pickedUp = false; // fire off event WindowEventArgs args(this); onDragEnded(args); } // check for sticky pick up else if (d_stickyMode && !d_pickedUp) { initialiseDragging(); d_pickedUp = true; // in this case, do not proceed to release inputs. return; } // release our capture on the input data releaseInput(); ++e.handled; } }
//----------------------------------------------------------------------------// bool DragContainer::pickUp(const bool force_sticky /*= false*/) { // check if we're already picked up or if dragging is disabled. if (d_pickedUp || !d_draggingEnabled) return true; // see if we need to force sticky mode switch if (!d_stickyMode && force_sticky) setStickyModeEnabled(true); // can only pick up if sticky if (d_stickyMode) { // force immediate release of any current input capture (unless it's us) if (d_captureWindow && d_captureWindow != this) d_captureWindow->releaseInput(); // activate ourselves and try to capture input activate(); if (captureInput()) { // set the dragging point to the centre of the container. d_dragPoint.d_x = cegui_absdim(d_pixelSize.d_width / 2); d_dragPoint.d_y = cegui_absdim(d_pixelSize.d_height / 2); // initialise the dragging state initialiseDragging(); // get position of mouse as co-ordinates local to this window. const Vector2 localMousePos(CoordConverter::screenToWindow(*this, MouseCursor::getSingleton().getPosition())); doDragging(localMousePos); d_pickedUp = true; } } return d_pickedUp; }
void DragContainer::onDragStarted(WindowEventArgs& e) { initialiseDragging(); fireEvent(EventDragStarted, e, EventNamespace); }