Correct cursor for search control buttons.

This commit is contained in:
Jeff Young 2021-11-18 18:25:14 +00:00
parent 7bda077f69
commit 4e6a201881
2 changed files with 17 additions and 0 deletions

View File

@ -77,6 +77,7 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
m_query_ctrl->Bind( wxEVT_SEARCHCTRL_CANCEL_BTN, &LIB_TREE::onQueryText, this );
#endif
m_query_ctrl->Bind( wxEVT_CHAR_HOOK, &LIB_TREE::onQueryCharHook, this );
m_query_ctrl->Bind( wxEVT_MOTION, &LIB_TREE::onQueryMouseMoved, this );
Bind( wxEVT_TIMER, &LIB_TREE::onDebounceTimer, this, m_debounceTimer->GetId() );
@ -434,6 +435,21 @@ void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke )
}
void LIB_TREE::onQueryMouseMoved( wxMouseEvent& aEvent )
{
wxPoint pos = aEvent.GetPosition();
wxRect ctrlRect = m_query_ctrl->GetScreenRect();
int buttonWidth = ctrlRect.GetHeight(); // Presume buttons are square
if( m_query_ctrl->IsSearchButtonVisible() && pos.x < buttonWidth )
SetCursor( wxCURSOR_ARROW );
else if( m_query_ctrl->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
SetCursor( wxCURSOR_ARROW );
else
SetCursor( wxCURSOR_IBEAM );
}
void LIB_TREE::onTreeSelect( wxDataViewEvent& aEvent )
{
if( !m_tree_ctrl->IsFrozen() )

View File

@ -161,6 +161,7 @@ protected:
void onQueryText( wxCommandEvent& aEvent );
void onQueryEnter( wxCommandEvent& aEvent );
void onQueryCharHook( wxKeyEvent& aEvent );
void onQueryMouseMoved( wxMouseEvent& aEvent );
void onTreeSelect( wxDataViewEvent& aEvent );
void onTreeActivate( wxDataViewEvent& aEvent );