Author Topic: Ticket 625:[incrementalSearch] On windows not possible to get focus by clicking  (Read 4369 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
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...

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
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.
« Last Edit: March 03, 2018, 01:50:44 pm by Miguel Gimenez »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
But you're searching for all the things you type - it is named incremental search after all :)
Probably it could be made more clever...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
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.


Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
I have been bitten again by this bug in another computer, just wanted to pop the thread so the proposed solution is not forgotten

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Would like to ping this problem....