MCPcopy Create free account
hub / github.com/audacity/audacity / OnMouseEvent

Method OnMouseEvent

src/widgets/AButton.cpp:479–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477}
478
479void AButton::OnMouseEvent(wxMouseEvent & event)
480{
481 wxSize clientSize = GetClientSize();
482 AButtonState prevState = GetState();
483
484 if (event.Entering()) {
485 // Bug 1201: On Mac, unsetting and re-setting the tooltip may be needed
486 // to make it pop up when we want it.
487 auto text = GetToolTipText();
488 UnsetToolTip();
489 wxWindow::SetToolTip(text);
490 mCursorIsInWindow = true;
491 }
492 else if (event.Leaving())
493 mCursorIsInWindow = false;
494 else
495 mCursorIsInWindow =
496 (event.m_x >= 0 && event.m_y >= 0 &&
497 event.m_x < clientSize.x && event.m_y < clientSize.y);
498
499 if (mEnabled && event.IsButton()) {
500 if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
501 mIsClicking = true;
502 if (event.ButtonDClick())
503 mIsDoubleClicked = true;
504 if( !HasCapture() )
505 CaptureMouse();
506 }
507 else if (mIsClicking) {
508 mIsClicking = false;
509
510 if (HasCapture())
511 ReleaseMouse();
512
513 if (mCursorIsInWindow && (mToggle || !mButtonIsDown)) {
514 if (mToggle)
515 mButtonIsDown = !mButtonIsDown;
516
517 mWasShiftDown = event.ShiftDown();
518 mWasControlDown = event.ControlDown();
519
520 Click();
521 }
522 }
523 }
524
525 // Only redraw and change tooltips if the state has changed.
526 AButtonState newState = GetState();
527
528 if (newState != prevState) {
529 Refresh(false);
530
531 if (mCursorIsInWindow)
532 UpdateStatus();
533 else {
534 auto pProject = FindProjectFromWindow( this );
535 if (pProject)
536 ProjectStatus::Get( *pProject ).Set({});

Callers

nothing calls this directly

Calls 4

FindProjectFromWindowFunction · 0.85
GetFunction · 0.85
SkipMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected