Opened 7 years ago

Closed 7 years ago

#12177 closed defect (fixed)

wxValidators do not have a chance to be triggered when a custom event handler is pushed on a control

Reported by: lucak Owned by:
Priority: normal Milestone: 3.0.0
Component: GUI-all Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: yes

Description

Hello,

I updated to last trunk of wxWidgets for MSW, and my own custom
validators do not work anymore. The scenario is the following:
-a wxTextCtrl with an associated wxValidator derived class;
-a wxEvtHandler derived class pushed on the wxTextCtrl;

In this case, as the patch show, the non-digit characters could be typed inside the textctrl although the validator should allow only digits to be typed (it has a wxTextValidator with wxFILYTER_DIGITS style).

I investigated a bit the problem, and it seems
that when the CustomEventHandler is pushed on, then typing a alpha key (while the cursor is in the
wxTextCtrl of course) the first event handler to be called is the
custom one, and since it is not eaten then it passes the event to the wxTextCtrl event handler, but in

bool wxEvtHandler::DoTryChain(wxEvent& event)

the event is marked as "process it only here", i.e. in the current
event handler.
Afterwards, when the event reach the function

bool wxEvtHandler::ProcessEvent(wxEvent& event)
[...]
if ( event.ShouldProcessOnlyIn(this) )

return TryHere(event);

[...]
if ( ProcessEventLocally(event) )
[...]

TryHere() is called instead of ProcessEventLocally(), and in
TryHere()
there is not a call to the chained event handlers, (like the
ProcessEventLocally
would do calling DoTryChain()), and the event is not forwarded to the
wxValidator.

Attachments (1)

validators_trunk.patch download (1.6 KB) - added by lucak 7 years ago.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by lucak

comment:1 Changed 7 years ago by VZ

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

(In [65006]) Ensure that validators work even in presence of pushed event handlers.

Call pre-processing hooks for each of the handlers in the chain and not only
the first one. This ensures that a validator (which is invoked during the
pre-processing stage) of a window is used even if a window has an event
handler pushed on top of it.

Closes #12177.

Note: See TracTickets for help on using tickets.