-
-
Notifications
You must be signed in to change notification settings - Fork 690
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
[widget audit] TextInput, PasswordInput #1944
Conversation
b69882a
to
2b96f4d
Compare
aee109b
to
0fc3141
Compare
0fc3141
to
b3bba0d
Compare
9afbfb8
to
b22c064
Compare
{ directory = "feature", name = "Features", showcontent = true }, | ||
{ directory = "bugfix", name = "Bugfixes", showcontent = true }, | ||
{ directory = "removal", name = "Backward Incompatible Changes", showcontent = true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't backward incompatible changes come first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my take would be that you talk about the awesome new stuff before you scare people with the things that have changed :-)
As a comparable example - Django's release notes list major features, minor features, then backwards incompatibilities.
core/src/toga/widgets/textinput.py
Outdated
def validate(self) -> bool: | ||
"""Validate the current value of the widget. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since validation happens automatically on both programmatic and user-generated changes, is there any reason for this method to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason for it to be public (other than, at this point, backwards compatibility). At the very least, it's worth flagging in docs that end-users shouldn't ever need to call this method; but I wouldn't be opposed to making it an internal method (with the appropriate backwards compatibility note).
def winforms_double_click(self, sender, event): | ||
self.native.SelectAll() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this was here: double-clicking on Windows is supposed to select one word, not the entire box.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I can't explain this one either.
def winforms_validated(self, sender, event): | ||
self.interface.validate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't work out what the Validated event handler was supposed to do, but everything seems to work fine without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Winforms provides explicit event hooks to perform validation independent of focus and text change; I think the intention is that you can prevent a widget from losing focus if it's not currently valid. However, we're not blocking focus in that way, so I guess we can just piggyback on the change event.
def assert_height(self, min_height, max_height): | ||
# Height isn't configurable in this native widget. | ||
assert 12 <= self.height <= 22 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The native TextBox seems to ignore its height allocation and always stay the same height. Does this happen with any other widgets? I think I remember us talking about it, but I can't find any similar implementations of this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some similar behavior with Button. Buttons don't expand to fill the available vertical space unless they're explicitly set to a given height.
There's also some similar (but inconsistent) behavior with Switch. On most platforms, the switch "graphic" is a fixed height, regardless of the containing box; however, GTK and iOS both violate this, and render the switch with a weird aspect ratio.
In this case, I'm happy to call this a platform eccentricity and document it.
Co-authored-by: Malcolm Smith <smith@chaquo.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freakboy3742: All platforms now have 100% coverage, and a fully-working textinput
example. Please review my last few commits, and merge the PR if you're happy.
@mhsmith One minor tweak (avoiding the use of ObjC invocations for validation), but otherwise this all looks good to me. |
Audit of both TextInput and PasswordInput (since they're essentially the same widget).
Extends #1938, as there's a lot of shared functionality in the probe.
There are some backwards incompatible changes in the API of individual Validators. Since it's a fairly niche feature, that wasn't previously documented (although there was example code), I didn't think it was worth a full backwards compatibility path.
Modifies the implementation of validation on macOS so that it doesn't require modal dialogs
Adds confirmation handling on macOS
Adds an implementation of focus handling, confirmation handling and validation on iOS.
Fixes #1290.
Fixes #1315.
Audit checklist