Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: BlueHazzard on March 02, 2018, 08:56:01 pm

Title: Ticket 625:[incrementalSearch] On windows not possible to get focus by clicking
Post by: BlueHazzard on March 02, 2018, 08:56:01 pm
SF ticker text:
Quote
On windows (win 7) with wxWidgets >3.0 (confirmed with 3.1) it is no longer possible to set the cursor in the incrementalSearch toolbar text ctrl after removing its focus. Steps to reproduce:
1) Open a project
2) Enable the incrementalSearch toolbar with view->Toolbars->IncrementalSearch
3) Search for something non existent from the toolbars text control (see 2) down)
4) After the control gets red click in the editor outside the toolbar
5) You are no longer able to set the cursor back in the toolbar control to change the text. Every text you enter will be entered in the editor.

More observations:
1) You can regain the focus of the control if you click any button in the incremental search toolbar, and after that click in the text control.
2) This behaviour happens also if the searched text is found

I think i have found the reason:
http://docs.wxwidgets.org/trunk/classwx_focus_event.html
Quote
The focus event handlers should almost invariably call wxEvent::Skip() on their event argument to allow the default handling to take place. Failure to do this may result in incorrect behaviour of the native controls. Also note that wxEVT_KILL_FOCUS handler must not call wxWindow::SetFocus() as this, again, is not supported by all native controls. If you need to do this, consider using the Delayed Action Mechanism described in wxIdleEvent documentation.

in src\plugins\contrib\IncrementalSearch\IncrementalSearch.cpp:548
Code
void IncrementalSearch::OnKillFocus(wxCommandEvent& event)
{
    if(m_pTextCtrl)
    {
        m_LastInsertionPoint = m_pTextCtrl->GetInsertionPoint();
    }
}
is no wxEvent::Skip()  call.
if i add this call
Code
void IncrementalSearch::OnKillFocus(wxCommandEvent& event)
{
    event.Skip();
    if(m_pTextCtrl)
    {
        m_LastInsertionPoint = m_pTextCtrl->GetInsertionPoint();
    }
}

all works as expected.

i will post a patch on SF as soon as they are up again.

It would be great if someone can test this on windows...
Title: Re: Ticket 625:[incrementalSearch] On windows not possible to get focus by clicking
Post by: Miguel Gimenez on March 03, 2018, 01:45:26 pm
Works for me on W7 32 bits with GCC 7.2.0  and wxWidgets 3.1.0. Before the patch it lost focus forever just by clicking on tre drop down button.

I put the call to Skip() at the end of the function, as it is usually done.

NOTE: I find weird the behaviour of the combobox, it stores everything I write; if I search for WEIRD it will show W, WE, WEI, WEIR and WEIRD when dropped down.
Title: Re: Ticket 625:[incrementalSearch] On windows not possible to get focus by clicking
Post by: oBFusCATed on March 03, 2018, 01:56:46 pm
But you're searching for all the things you type - it is named incremental search after all :)
Probably it could be made more clever...
Title: Re: Ticket 625:[incrementalSearch] On windows not possible to get focus by clicking
Post by: Jenna on March 03, 2018, 05:59:02 pm
The event.Skip() should be harmless in any cases.
I will add it if sf is up again.
About the incremental search-list.
It should be possible to make it configurable, so it's possible to store only the last found string (the longest), not all steps before.

Title: Re: Ticket 625:[incrementalSearch] On windows not possible to get focus by clicking
Post by: Miguel Gimenez on March 14, 2018, 05:58:32 pm
I have been bitten again by this bug in another computer, just wanted to pop the thread so the proposed solution is not forgotten
Title: Re: Ticket 625:[incrementalSearch] On windows not possible to get focus by clicking
Post by: BlueHazzard on June 04, 2018, 12:54:50 pm
Would like to ping this problem....