Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve wxValidators (3rd attempt) #24282

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

AliKet
Copy link
Contributor

@AliKet AliKet commented Feb 4, 2024

It's also nice to see these features implemented in wxWidgets:

  • Add wxRegexValidator for regular expression validations.
  • Make wxValidators generate events to report validation failure/success. Or...
  • Add wxValidatorProxy and let users customize validation behaviours:
    • Use wxRichToolTip to show error messages instead of the default message box.
    • Choose to revert to the previous valid value instead of clamping the value.
  • Do not generate wxEVT_TEXT event while the wxDialog/wxPanel is initialized due to calling SetValue() in the process of transferring data to window (TransferToWindow())

wxValidatorProxy might look like this:

class wxValidatorProxy
{
public:
    wxValidatorProxy() = default;
    virtual ~wxValidatorProxy() = default;

    // Return false to prevent default processing to take place

    virtual bool OnSuccess() const { return true; }
    virtual bool OnFailure(/*...*/) const { return true; }
    virtual bool OnIncompleteEntry(/*...*/) const { return true; }
};

Thanks for any other ideas!

ali kettab added 2 commits February 4, 2024 14:46
No real changes, just a refactoring to reduce code duplication between
wxTextValidator and wxNumValidator.
By moving the OnPaste() handler to the wxTextEntryValidator base class and
check whether the text can be pasted or not in the added CanPaste() function.
ali kettab added 2 commits February 4, 2024 22:41
This class uses wxRegEx to validate input strings in a text-like controls.

Deriving from wxTextValidator is about making the regular expression a little
shorter, understandable and powerful at the same time.

Do not use any of the wxTextValidator wxFILTER_XXX styles other than wxFILTER_NONE,
if the validator should only validate against the regular expression.
@AliKet AliKet marked this pull request as draft February 12, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant