Skip to content

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.

1 participant