-
-
Notifications
You must be signed in to change notification settings - Fork 672
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] toga.MultilineTextInput #1938
Conversation
@@ -14,9 +17,8 @@ | |||
|
|||
class TogaTextView(NSTextView): | |||
@objc_method | |||
def touchBar(self): | |||
# Disable the touchbar. | |||
return None |
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.
This was needed in the past to avoid a crash if the app ran on a MacBook with a Touch Bar; however, touchbars are no longer present on modern Macs, and in my testing on an older macBook with a Touch Bar, the bug no longer manifests.
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 Android implementation is now complete, though there are still some bugs with scrolling and background colors which I'll look at tomorrow.
Meanwhile, here's a partial review:
@property | ||
def placeholder(self): | ||
"""The placeholder text. | ||
"""The placeholder text for 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.
This, and the other properties, should have type annotations, as in Slider. At some point we should go back and do all the other widgets as well – but not in this PR, because it's big enough already.
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.
Agreed - I noticed this myself when working on TextInput; I'll wait for you to finish your pass so I don't step on your toes (or, if you feel enthused, feel free to add annotations yourself)
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.
Scratch that - I'll do a pass now. Can't step on your toes while you're asleep :-)
async def wait_for_scroll_completion(self): | ||
position = self.vertical_scroll_position | ||
current = None |
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 no platform-specific code in this method, so it could be moved to the testbed and avoid having empty implementations for all the other backends.
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.
Agreed it would be desirable to avoid needing to define an empty method; however, it would require introducing a sleep into platforms that don't need 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.
[Non-deleteable comment caused by GitHub glitch]
@property | ||
def vertical_alignment(self): | ||
return toga_vertical_alignment(self.native.getGravity()) |
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.
This will have to be implemented by the other backends.
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've done this for iOS, Cocoa, GTK and Winforms; although for iOS and Cocoa, it's a bit of a non-test because there's literally no property to inspect to verify vertical alignment - it's just what the widget does (or, in the case of iOS Label, what the widget has been overridden to do).
In the process of debugging a test for NumberInput, I've found a bug with all the text input APIs - we've overloaded the The I can see a couple of ways forward:
I'm not sure which one I prefer at this point, but I probably fall somewhere between 2 and 3. Thoughts @mhsmith? |
I think we should go with 2. Remove |
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.
Should these be here, or in android.graphics?
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.
At some point we should remove the libs
folder and use Chaquopy's from ... import ...
syntax, so we don't need to edit 2 files every time we import a new class. To make it easy to do that with a simple search and replace, I've made drawable
a submodule of graphics
.
Done - I've removed it (and added a deprecation note). |
Since Winforms displays the widget's value and placeholder through the same mechanism, only one of them at a time can be retrieved through the native API. So I've merged the I also added a few additional assertions, one of which verifies that a typed character is actually visible after the on_change event fires. The assertion is currently on |
5a71b9d
to
e687898
Compare
Success!! I've cleaned up the iOS error - the cause was a weird edge case where the widget already had focus, and was programmatically cleared. The same error was technically present on GTK (and I think Windows) as well, but wasn't visible because of the way the keyboard handler was triggering. I've also done a small cleanup on the Winforms implementation, removing the need for a proxied copy of the text of the widget; and added a documentation note about the color limitations on Winforms transparent backgrounds. With that, I'm happy with what is here; if you're happy to, we're good to merge! |
Audit checklist