void LWSlider::OnMouseEvent(wxMouseEvent & event) { if (event.Entering()) { // Display the tooltip in the status bar if (mParent->GetToolTip()) { wxString tip = mParent->GetToolTip()->GetTip(); GetActiveProject()->TP_DisplayStatusMessage(tip, 0); Refresh(); } } else if (event.Leaving()) { GetActiveProject()->TP_DisplayStatusMessage("",0); Refresh(); } float prevValue = mCurrentValue; if (event.ButtonDown()) { //This jumps the thumb to clicked position if (!mIsDragging) { mCurrentValue = PositionToValue(event.m_x, event.ShiftDown()); mIsDragging = true; mParent->CaptureMouse(); FormatPopWin(); SetPopWinPosition(); mPopWin->Show(); } // Don't generate notification yet return; } else if (event.ButtonUp() && mIsDragging) { mIsDragging = false; mParent->ReleaseMouse(); mPopWin->Hide(); ((TipPanel *)mPopWin)->SetPos(wxPoint(-1000, -1000)); } else if (event.Dragging() && mIsDragging) { mCurrentValue = PositionToValue(event.m_x, event.ShiftDown()); } if (prevValue != mCurrentValue) { FormatPopWin(); mPopWin->Refresh(); Refresh(); wxCommandEvent *e = new wxCommandEvent(wxEVT_COMMAND_SLIDER_UPDATED, mID); int intValue = (int)((mCurrentValue - mMinValue) * 1000.0f / (mMaxValue - mMinValue)); e->SetInt( intValue ); mParent->ProcessEvent(*e); delete e; } }
FReply SSlider::OnMouseMove( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) { if (this->HasMouseCapture() && !IsLocked()) { SetCursor((Orientation == Orient_Horizontal) ? EMouseCursor::ResizeLeftRight : EMouseCursor::ResizeUpDown); CommitValue(PositionToValue(MyGeometry, MouseEvent.GetLastScreenSpacePosition())); // Release capture for controller/keyboard when switching to mouse ResetControllerState(); return FReply::Handled(); } return FReply::Unhandled(); }
FReply SSlider::OnMouseButtonDown( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) { if ((MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton) && !IsLocked()) { OnMouseCaptureBegin.ExecuteIfBound(); CommitValue(PositionToValue(MyGeometry, MouseEvent.GetLastScreenSpacePosition())); // Release capture for controller/keyboard when switching to mouse. ResetControllerState(); return FReply::Handled().CaptureMouse(SharedThis(this)); } return FReply::Unhandled(); }