Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#14970 closed defect (fixed)

SearchCtrl HasFocus() doesn't report correct status

Reported by: fhjull00 Owned by:
Priority: normal Milestone:
Component: wxPython Version: 2.9.4
Keywords: SearchCtrl, HasFocus Cc:
Blocked By: Blocking:
Patch: no

Description

SearchCtrl control doesn't seem to return HasFocus() correctly - when cursor is inside SearchCtrl TextCtrl, then

print searchCtrl.HasFocus()
>>> False

The workaround is to get list of children and query focus for them:

for searchFieldChild in searchCtrl.GetChildren():
   print searchFieldChild, searchFieldChild.HasFocus()

>>> <wx._controls.TextCtrl; proxy of <Swig Object of type 'wxTextCtrl *' at 0x40ae5e8> > True
>>> <wx._core.Control; proxy of <Swig Object of type 'wxControl *' at 0x3f9b7b0> > False
>>> <wx._core.Control; proxy of <Swig Object of type 'wxControl *' at 0x3f9c3b8> > False

Is this desired or should TextCtrl portion of SearchCtrl return the same HasFocus() value as SearchCtrl itself?

I am using wxPython 2.9.4.0 on Windows 7 x64 with Python 2.7 (x32).

Change History (2)

comment:1 Changed 15 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73401]) Fix wxSearchCtrl::HasFocus() in the generic version.

Override GetMainWindowOfCompositeControl() in the windows composing the
generic wxSearchCtrl to ensure that HasFocus() correctly returns true for the
entire control when any of them has focus.

Add a trivial unit test to check that this really works and facilitate adding
more tests for this class later.

Closes #14970.

comment:2 Changed 15 months ago by fhjull00

Thank you!

Note: See TracTickets for help on using tickets.