Data Validation

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
RadioHam
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Feb 15, 2021 11:08 pm

Data Validation

Post by RadioHam »

I think this has been covered elsewhere, but many years ago. Others seemed to have the same problem then.

When using validators in a dialog and you have an OK button with OnOkClick function using wxID_OK, the documentation says it is supposed to automatically call TransferDataFromWindow(). I have not been able to get this to work unless I add TransferDataFromWindow(); to my OnOkClick function.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Data Validation

Post by doublemax »

Do you call event.Skip() in the wxID_OK button event handler, so that the default behavior gets executed, too?
Use the source, Luke!
User avatar
RadioHam
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Feb 15, 2021 11:08 pm

Re: Data Validation

Post by RadioHam »

No I did not call event.Skip(); Somehow I missed that requirement in my understanding of wxWidgets.
Now that I add that call, I can remove the manual call of TransferDataFromWindow() and it works as it should.Thank you so much.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Data Validation

Post by doublemax »

RadioHam wrote: Fri Mar 26, 2021 4:25 pm No I did not call event.Skip(); Somehow I missed that requirement in my understanding of wxWidgets.
That's not a general requirement, it depends on the case. The name of the method does not make very clear what it does. Think of it as "ContinueProcessing()". That means if you call event.Skip(), other event handlers for the same event will get executed. Otherwise they will not. Normally you do not call event.Skip() for command event handlers like button or menu events, but in this particular case you have to so that the dialog's event handler for that event gets executed.
Use the source, Luke!
Post Reply