mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-17 09:07:41 +02:00
Bug1917: TrackPanel should keep focus after click or drag...
... though ruler won't, and if you start to drag in TrackPanel but abort it with the ESC key, that too returns focus
This commit is contained in:
parent
3f0b3bf1b8
commit
22f85f244b
@ -94,7 +94,7 @@ void CellularPanel::HandleInterruptedDrag()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellularPanel::Uncapture(wxMouseState *pState)
|
void CellularPanel::Uncapture(bool escaping, wxMouseState *pState)
|
||||||
{
|
{
|
||||||
auto state = ::wxGetMouseState();
|
auto state = ::wxGetMouseState();
|
||||||
if (!pState) {
|
if (!pState) {
|
||||||
@ -107,12 +107,14 @@ void CellularPanel::Uncapture(wxMouseState *pState)
|
|||||||
ReleaseMouse();
|
ReleaseMouse();
|
||||||
HandleMotion( *pState );
|
HandleMotion( *pState );
|
||||||
|
|
||||||
auto lender = GetProject()->mFocusLender.get();
|
if (escaping || !TakesFocus()) {
|
||||||
if (lender)
|
auto lender = GetProject()->mFocusLender.get();
|
||||||
lender->SetFocus();
|
if (lender)
|
||||||
|
lender->SetFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellularPanel::CancelDragging()
|
bool CellularPanel::CancelDragging( bool escaping )
|
||||||
{
|
{
|
||||||
auto &state = *mState;
|
auto &state = *mState;
|
||||||
if (state.mUIHandle) {
|
if (state.mUIHandle) {
|
||||||
@ -127,7 +129,7 @@ bool CellularPanel::CancelDragging()
|
|||||||
refreshResult | state.mMouseOverUpdateFlags );
|
refreshResult | state.mMouseOverUpdateFlags );
|
||||||
state.mpClickedCell.reset();
|
state.mpClickedCell.reset();
|
||||||
state.mUIHandle.reset(), handle.reset(), ClearTargets();
|
state.mUIHandle.reset(), handle.reset(), ClearTargets();
|
||||||
Uncapture();
|
Uncapture( escaping );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -148,7 +150,7 @@ bool CellularPanel::HandleEscapeKey(bool down)
|
|||||||
|
|
||||||
auto &state = *mState;
|
auto &state = *mState;
|
||||||
if (state.mUIHandle) {
|
if (state.mUIHandle) {
|
||||||
CancelDragging();
|
CancelDragging( true );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,7 +692,7 @@ try
|
|||||||
::wxGetMouseState().ButtonIsDown(wxMOUSE_BTN_ANY);
|
::wxGetMouseState().ButtonIsDown(wxMOUSE_BTN_ANY);
|
||||||
|
|
||||||
if(!buttons) {
|
if(!buttons) {
|
||||||
CancelDragging();
|
CancelDragging( false );
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
|
|
||||||
@ -717,7 +719,7 @@ try
|
|||||||
// Drag decided to abort itself
|
// Drag decided to abort itself
|
||||||
state.mUIHandle.reset(), handle.reset(), ClearTargets();
|
state.mUIHandle.reset(), handle.reset(), ClearTargets();
|
||||||
state.mpClickedCell.reset();
|
state.mpClickedCell.reset();
|
||||||
Uncapture( &event );
|
Uncapture( false, &event );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
UpdateMouseState(event);
|
UpdateMouseState(event);
|
||||||
@ -753,15 +755,15 @@ try
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.ButtonUp())
|
if (event.ButtonUp())
|
||||||
Uncapture();
|
Uncapture( false );
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
// Abort any dragging, as if by hitting Esc
|
// Abort any dragging, as if by hitting Esc
|
||||||
if ( CancelDragging() )
|
if ( CancelDragging( true ) )
|
||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
Uncapture();
|
Uncapture( true );
|
||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
|
@ -58,6 +58,10 @@ public:
|
|||||||
|
|
||||||
virtual void UpdateStatusMessage( const wxString & ) = 0;
|
virtual void UpdateStatusMessage( const wxString & ) = 0;
|
||||||
|
|
||||||
|
// Whether this panel keeps focus after a click and drag, or only borrows
|
||||||
|
// it.
|
||||||
|
virtual bool TakesFocus() const = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UIHandlePtr Target();
|
UIHandlePtr Target();
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool HasEscape();
|
bool HasEscape();
|
||||||
bool CancelDragging();
|
bool CancelDragging( bool escaping );
|
||||||
void DoContextMenu( TrackPanelCell *pCell = nullptr );
|
void DoContextMenu( TrackPanelCell *pCell = nullptr );
|
||||||
void ClearTargets();
|
void ClearTargets();
|
||||||
|
|
||||||
@ -92,7 +96,7 @@ private:
|
|||||||
void OnContextMenu(wxContextMenuEvent & event);
|
void OnContextMenu(wxContextMenuEvent & event);
|
||||||
|
|
||||||
void HandleInterruptedDrag();
|
void HandleInterruptedDrag();
|
||||||
void Uncapture( wxMouseState *pState = nullptr );
|
void Uncapture( bool escaping, wxMouseState *pState = nullptr );
|
||||||
bool HandleEscapeKey(bool down);
|
bool HandleEscapeKey(bool down);
|
||||||
void UpdateMouseState(const wxMouseState &state);
|
void UpdateMouseState(const wxMouseState &state);
|
||||||
void HandleModifierKey();
|
void HandleModifierKey();
|
||||||
|
@ -721,6 +721,11 @@ void TrackPanel::UpdateStatusMessage( const wxString &st )
|
|||||||
mListener->TP_DisplayStatusMessage(status);
|
mListener->TP_DisplayStatusMessage(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TrackPanel::TakesFocus() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void TrackPanel::UpdateSelectionDisplay()
|
void TrackPanel::UpdateSelectionDisplay()
|
||||||
{
|
{
|
||||||
// Full refresh since the label area may need to indicate
|
// Full refresh since the label area may need to indicate
|
||||||
|
@ -482,6 +482,8 @@ protected:
|
|||||||
|
|
||||||
void UpdateStatusMessage( const wxString &status ) override;
|
void UpdateStatusMessage( const wxString &status ) override;
|
||||||
|
|
||||||
|
bool TakesFocus() const override;
|
||||||
|
|
||||||
// friending GetInfoCommand allow automation to get sizes of the
|
// friending GetInfoCommand allow automation to get sizes of the
|
||||||
// tracks, track control panel and such.
|
// tracks, track control panel and such.
|
||||||
friend class GetInfoCommand;
|
friend class GetInfoCommand;
|
||||||
|
@ -2727,7 +2727,7 @@ void AdornedRulerPanel::OnRecordStartStop(wxCommandEvent & evt)
|
|||||||
if (evt.GetInt() != 0)
|
if (evt.GetInt() != 0)
|
||||||
{
|
{
|
||||||
mIsRecording = true;
|
mIsRecording = true;
|
||||||
this->CellularPanel::CancelDragging();
|
this->CellularPanel::CancelDragging( false );
|
||||||
this->CellularPanel::ClearTargets();
|
this->CellularPanel::ClearTargets();
|
||||||
|
|
||||||
UpdateButtonStates();
|
UpdateButtonStates();
|
||||||
@ -3780,6 +3780,11 @@ void AdornedRulerPanel::UpdateStatusMessage( const wxString &message )
|
|||||||
GetProject()->TP_DisplayStatusMessage(message);
|
GetProject()->TP_DisplayStatusMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AdornedRulerPanel::TakesFocus() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::CreateOverlays()
|
void AdornedRulerPanel::CreateOverlays()
|
||||||
{
|
{
|
||||||
if (!mOverlay)
|
if (!mOverlay)
|
||||||
|
@ -466,6 +466,8 @@ private:
|
|||||||
|
|
||||||
void UpdateStatusMessage( const wxString & ) override;
|
void UpdateStatusMessage( const wxString & ) override;
|
||||||
|
|
||||||
|
bool TakesFocus() const override;
|
||||||
|
|
||||||
void CreateOverlays();
|
void CreateOverlays();
|
||||||
|
|
||||||
// Cooperating objects
|
// Cooperating objects
|
||||||
|
Loading…
x
Reference in New Issue
Block a user