C++ (Cpp) wxMouseCaptureChangedEvent Example

Introduction

The c++ (cpp) wxmousecapturechangedevent example is extracted from the most popular open source projects, you can refer to the following example for usage.

Programming language: C++ (Cpp)

Class/type: wxMouseCaptureChangedEvent

Example#1
File: WXSceneCanvas.cppProject: jjiezheng/pap_full

void ActorSceneCanvas::OnMouseCaptureChanged(wxMouseCaptureChangedEvent& e)
{
    if (e.GetEventObject() == this && e.GetCapturedWindow() != this)
    {
        switch (mDragButton)
        {
        case wxMOUSE_BTN_MIDDLE:
            {
                wxASSERT(m_pCameraManip);
                wxPoint pt = wxGetMousePosition();
                pt = ScreenToClient(pt);
                m_pCameraManip->onEnd(pt.x, pt.y, true);
                m_pCameraManip = NULL;
                break;
            }

        case wxMOUSE_BTN_LEFT:
            {
                //wxASSERT(GetActiveAction());
                //wxPoint pt = wxGetMousePosition();
                //pt = ScreenToClient(pt);
                //GetActiveAction()->onEnd(pt.x, pt.y, true);
                m_pUpdateListener->disable();
            }
            break;
        }

        mDragButton = wxMOUSE_BTN_NONE;
    }
}

Example#2
File: Stage.cppProject: colonelqubit/halyard

void Stage::OnMouseCaptureChanged(wxMouseCaptureChangedEvent &inEvent) {
    // According to the manual: "An mouse capture changed event is sent to
    // a window that loses its mouse capture."  Theoretically, this means
    // that we should *never* receive this event to notify us that we
    // *regained* a mouse capture.  However, there's a stack of mouse
    // captures in wxWidgets, and the event name is suspiciously
    // ambiguous, so we're going to check.
    ASSERT(inEvent.GetCapturedWindow() != this);

    // Clear the grabbed element.  Note that this code will be run whenever
    // we lose the mouse grab (at least on Windows, where this event is
    // implemented), even if it's because MouseUngrab called ReleaseMouse
    // directly.  So this may be redudant 99% of the time on windows.  But
    // the other 1% of the time, it happens because somebody popped up an
    // error window while the mouse was grabbed.
    mGrabbedElement = ElementPtr();
}