-
-
Notifications
You must be signed in to change notification settings - Fork 684
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
5cac536
Audit docs and core tests for MultilineTextInput.
freakboy3742 5429acc
WIP
freakboy3742 c0cf0f3
Cocoa MultilineTextView to 100% coverage.
freakboy3742 cc80700
iOS to 100% coverage.
freakboy3742 8fa3aa9
Add Changenote.
freakboy3742 9096f52
Use the UIKeyInput protocol to fake keyboard input.
freakboy3742 cf9da9c
Ensure a redraw includes at an event loop tick on macOS.
freakboy3742 5800c40
Spelling corrections in docstrings.
freakboy3742 6a5be8a
Tweaked some test docstrings.
freakboy3742 d89e49c
Gtk implementation to 100%
freakboy3742 2f8f214
Enable GTK focus tests.
freakboy3742 7aea2d0
Add a window manager to the GTK CI config.
freakboy3742 7fceda3
Correct iOS placeholder test definition.
freakboy3742 ead982d
Android WIP
mhsmith 43759f9
Merge branch 'main' into audit-multilinetext
freakboy3742 c763aa9
Add type annotations.
freakboy3742 4cdab2c
Tweaked some docs formatting.
freakboy3742 ff27cde
Simplified some probe handling.
freakboy3742 e636a1f
Tweaked handling of on-change and enabled.
freakboy3742 98343dc
Correct GTK on_change handling.
freakboy3742 375d26c
Additional tolerance for scoll size.
freakboy3742 8ef583d
Another scrollbar tolerance tweak.
freakboy3742 838c6e4
Propegate widget descriptions to the API summary page.
freakboy3742 6dff342
Actually save all the changes before pushing...
freakboy3742 80ea9f6
Update Android for changes in testbed
mhsmith b3b8ed3
Add tests for vertical alignment, and fix on Android
mhsmith cbe63ec
Implement vertical alignment checks for GTK.
freakboy3742 9eec789
Removed and no-covered some unreachable and unused content in cocoa/i…
freakboy3742 2ff9920
Probe implementations (and widget implementation) for top vertical al…
freakboy3742 08c8d50
Added Winforms implementation and fix for vertical alignment.
freakboy3742 e379547
Fix Android background color
mhsmith 5db4c77
Android at 100% coverage
mhsmith be9ca2f
Deprecated the clear() method on text inputs.
freakboy3742 07abb24
Add allowance for minor GTK style differences.
freakboy3742 e9132f0
Update change note and support table
mhsmith df00658
Make libs/android/graphics/drawable match Java package structure
mhsmith bb71950
All Winforms tests passing except test_scroll_position
mhsmith 3ad5352
Winforms at 100% coverage
mhsmith e687898
Correct iOS test failure caused by focus.
freakboy3742 4ca8a9b
Document Winforms issue with TRANSPARENT backgrounds, and mainline th…
freakboy3742 87fffda
Correct GTK handling of clearing while focussed.
freakboy3742 fee4bb6
Simplify winforms implementation, removing proxy value.
freakboy3742 9f871ef
Winforms: fix interactions between placeholder and on_change handler
mhsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from rubicon.java import JavaClass | ||
|
||
ColorDrawable = JavaClass("android/graphics/drawable/ColorDrawable") | ||
InsetDrawable = JavaClass("android/graphics/drawable/InsetDrawable") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,72 @@ | ||
from travertino.size import at_least | ||
|
||
from toga.constants import LEFT | ||
|
||
from ..libs.android.text import InputType, TextWatcher | ||
from ..libs.android.view import Gravity | ||
from ..libs.android.widget import EditText | ||
from .base import align | ||
from .label import TextViewWidget | ||
|
||
|
||
class TogaTextWatcher(TextWatcher): | ||
def __init__(self, impl): | ||
super().__init__() | ||
self.impl = impl | ||
self.interface = impl.interface | ||
|
||
def beforeTextChanged(self, _charSequence, _start, _count, _after): | ||
pass | ||
|
||
def afterTextChanged(self, _editable): | ||
if self.interface.on_change: | ||
self.interface.on_change(widget=self.interface) | ||
self.interface.on_change(None) | ||
|
||
def onTextChanged(self, _charSequence, _start, _before, _count): | ||
pass | ||
|
||
|
||
class MultilineTextInput(TextViewWidget): | ||
def create(self): | ||
self._textChangedListener = None | ||
self.native = EditText(self._native_activity) | ||
self.native.setInputType( | ||
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | ||
) | ||
# Set default alignment | ||
self.set_alignment(LEFT) | ||
self.native.addTextChangedListener(TogaTextWatcher(self)) | ||
self.cache_textview_defaults() | ||
|
||
def get_value(self): | ||
return self.native.getText().toString() | ||
return str(self.native.getText()) | ||
|
||
def set_value(self, value): | ||
self.native.setText(value) | ||
|
||
def get_readonly(self): | ||
return not self.native.isFocusable() | ||
|
||
def set_readonly(self, value): | ||
self.native.setFocusable(not value) | ||
def set_readonly(self, readonly): | ||
if readonly: | ||
# Implicitly calls setFocusableInTouchMode(False) | ||
self.native.setFocusable(False) | ||
else: | ||
# Implicitly calls setFocusable(True) | ||
self.native.setFocusableInTouchMode(True) | ||
|
||
def get_placeholder(self): | ||
return str(self.native.getHint()) | ||
|
||
def set_placeholder(self, value): | ||
# Android EditText's setHint() requires a Python string. | ||
self.native.setHint(value if value is not None else "") | ||
self.native.setHint(value) | ||
|
||
def set_alignment(self, value): | ||
self.native.setGravity(Gravity.TOP | align(value)) | ||
|
||
def set_value(self, value): | ||
self.native.setText(value) | ||
self.set_textview_alignment(value, Gravity.TOP) | ||
|
||
def set_on_change(self, handler): | ||
if self._textChangedListener: | ||
self.native.removeTextChangedListener(self._textChangedListener) | ||
self._textChangedListener = TogaTextWatcher(self) | ||
self.native.addTextChangedListener(self._textChangedListener) | ||
def set_background_color(self, value): | ||
# This causes any custom color to hide the bottom border line, but it's better | ||
# than set_background_filter, which affects *only* the bottom border line. | ||
self.set_background_simple(value) | ||
|
||
def rehint(self): | ||
self.interface.intrinsic.width = at_least(self.interface._MIN_WIDTH) | ||
self.interface.intrinsic.height = at_least(self.interface._MIN_HEIGHT) | ||
|
||
def scroll_to_bottom(self): | ||
last_line = (self.native.getLineCount() - 1) * self.native.getLineHeight() | ||
self.native.scrollTo(0, last_line) | ||
self.native.setSelection(self.native.length()) | ||
|
||
def scroll_to_top(self): | ||
self.native.scrollTo(0, 0) | ||
self.native.setSelection(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Because of the getLayoutParams issue, this code was never previously running during widget creation. It turns out WebView doesn't even have a setGravity method.
It doesn't make any sense for WebView to support alignment anyway, so I've just removed the method.