private void beginDragging(final MouseDownEvent event) {
        getDragGlass().show();

        dragging = true;
        dragStartX = event.getClientX();
        dragStartY = event.getClientY();
        dragStartWindow = new Rect(getElement());
        resizeWidth = false;
        resizeHeight = false;
        moveX = false;
        moveY = false;

        final EventTarget target = event.getNativeEvent().getEventTarget();
        if (Element.is(target)) {
            final Element element = Element.as(target);
            if (resizeN.getElement().isOrHasChild(element)) {
                resizeHeight = true;
                moveY = true;
            } else if (resizeE.getElement().isOrHasChild(element)) {
                resizeWidth = true;
            } else if (resizeS.getElement().isOrHasChild(element)) {
                resizeHeight = true;
            } else if (resizeW.getElement().isOrHasChild(element)) {
                resizeWidth = true;
                moveX = true;
            } else if (resizeNE.getElement().isOrHasChild(element)) {
                resizeWidth = true;
                resizeHeight = true;
                moveY = true;
            } else if (resizeNW.getElement().isOrHasChild(element)) {
                resizeWidth = true;
                resizeHeight = true;
                moveX = true;
                moveY = true;
            } else if (resizeSE.getElement().isOrHasChild(element)) {
                resizeWidth = true;
                resizeHeight = true;
            } else if (resizeSW.getElement().isOrHasChild(element)) {
                resizeWidth = true;
                resizeHeight = true;
                moveX = true;
            }
        }

        // If we aren't resizing we are moving.
        if (!resizeWidth && !resizeHeight) {
            moveX = true;
            moveY = true;
        }

        DOM.setCapture(getElement());
    }
Called on mouse down in the caption area, begins the dragging loop by
turning on event capture.

@param event the mouse down event that triggered dragging
@see DOM#setCapture
@see #continueDragging
stroom-core-client-widget/src/main/java/stroom/widget/popup/client/view/ResizableDialog.java