-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Enhancement] Entry: Read-only Entry and Editor #1972
[Enhancement] Entry: Read-only Entry and Editor #1972
Conversation
@@ -19,6 +19,7 @@ public EntryRenderer() | |||
RegisterPropertyHandler(Entry.PlaceholderProperty, UpdatePlaceholder); | |||
RegisterPropertyHandler(Entry.PlaceholderColorProperty, UpdatePlaceholderColor); | |||
RegisterPropertyHandler(InputView.MaxLengthProperty, UpdateMaxLength); | |||
RegisterPropertyHandler(Entry.IsReadOnlyProperty, UpdateIsReadOnly); |
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 think the whitespace preceeding the if was lost here.
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.
You are right, I will fix that also :)
@@ -106,6 +107,10 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE | |||
UpdateMaxLength(); | |||
else if (e.PropertyName == Specifics.DetectReadingOrderFromContentProperty.PropertyName) | |||
UpdateDetectReadingOrderFromContent(); | |||
else if (e.PropertyName == InputView.IsReadOnlyProperty.PropertyName) | |||
{ |
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.
Can skip adding curly braces if there is a single statement nested under a predicate.
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 will fix this :)
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 is fine
@@ -146,5 +147,10 @@ string MaxLengthFilter(ElmSharp.Entry entry, string s) | |||
|
|||
return null; | |||
} | |||
|
|||
void UpdateIsReadOnly() |
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.
Can move this above MaxLengthFilter
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 will :)
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 is fine.
|
||
void UpdateIsReadOnly() | ||
{ | ||
Control.UserInteractionEnabled = !Element.IsReadOnly; |
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.
Just an FYI that UpdateEditable
is also changing UserInteractionEnabled
. If I set IsEnabled
to false, then the control becomes read-only even though IsReadOnly
is false.
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.
Also, please look at other renderers to see if they are doing similar work. We should make sure IsEnabled
and IsReadOnly
play nice together.
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.
Nice point, thanks! :) Will fix that
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.
"If I set IsEnabled to false, then the control becomes read-only even though IsReadOnly is false.".
Yes, the main task of this Enhancement is to make control ReadOnly without changing the look of it, so if you set IsEnabled to false it will be "read-only" and also it will have a look like it is disabled. But if you are using only IsReadOnly = true, it will become ReadOnly and the look will not change.
So, maybe the best approach is to set IsReadOnly to true if IsEnabled == false ? :)
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.
Rename UpdateIsReadOnly() to UpdateUserInteraction()
In UpdateEditable, change the assignment of UserInteractionEnabled to point at this function instead.
Then in this function, do
Control.UserInteractionEnabled = !Element.IsReadonly && Element.IsEnabled
I think that should work, but you get the gist. You need to account for both properties now.
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.
Thanks!
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.
Yap @adamped suggestion is the correct one, we should have 1 method to handle this, the others call this.
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.
Ok, and my personal deadline for this is like end of this weekend, we will see :)
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.
- Need to address the
IsEnabled
/IsReadOnly
possible conflicts raised by @adrianknight89. - Failing unit tests.
Thanks!
Hey @almirvuk do you think you can address the comments on the PR and rebase?! Thanks |
@rmarinho can you please take a look at this comment/question #1972 (comment) What do you think about this? Also I am very close to finishing this, I think I need to finish Unit Tests, I have made some changes but I am stuck and I need somebody opinion about IsEnabled/IsReadOnly behaviour... and resolving these conflicts with rebase will be easy. |
I made some changes for iOS EditorRenderer that was problematic in the last pull request. I still need to do rebase and see what is the problem with unit tests (if they are mandatory?)... Can you please take a look. Thanks! 🙂 |
Hey @almirvuk can you rebase , and yes unit tests are mandatory |
@rmarinho I will do this by the end of the tomorrow :) Thanks |
Unit tests and rebase, done ✔️ |
Obviously...there is a issue with my last push, I will fix this and do another one. Sorry 🙂 |
@PureWeen I invited you as collaborator on my fork repo, do I need to do anything else? :) |
@almirvuk that looks like it worked! thank you |
{ | ||
Control.Editable = !Element.IsReadOnly; | ||
if (Element.IsReadOnly && Control.Window?.FirstResponder == Control.CurrentEditor) | ||
Control.Window?.MakeFirstResponder(null); |
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.
{ | ||
Control.Editable = !Element.IsReadOnly; | ||
if (Element.IsReadOnly && Control.Window?.FirstResponder == Control.CurrentEditor) | ||
Control.Window?.MakeFirstResponder(null); |
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 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.
👍
Android UI test failures are on 39821 (not caused by this change, fixed by #4866) Once MacOS changes are approved we can merge |
Nice, thank you @PureWeen for the help with this PR 🤗 |
@almirvuk Thank you for the good work! Hopefully we can get it merged before the PRs anniversary next month |
- fixes #1678 - fixes #4834 * InputView BindableProperty IsReadOnly * Android Editor and Entry setup * MacOS Editor and Entry setup * Tizen Editor and Entry setup * UAP Editor and Entry setup * WPF Editor and Entry setup * iOS Editor and Entry setup * Issue1678 - TestContentPage added * Tests added * Tizen Editor and Entry fix * UI Test fix * Android fix for Entry and Editor. * Unit Tests fix. * Android Renderer first try. * MacOS Entry renderer small fix. * UpdateEditable fix. * Android Entry and Editor reduced number of calls to BP. * fix TestAttributes conflicts * Remove keyboard * [macOS] relinquish first responder * [Android] remove call to UpdateCursorSelection * [UWP] fix tabs
- fixes xamarin#1678 - fixes xamarin#4834 * InputView BindableProperty IsReadOnly * Android Editor and Entry setup * MacOS Editor and Entry setup * Tizen Editor and Entry setup * UAP Editor and Entry setup * WPF Editor and Entry setup * iOS Editor and Entry setup * Issue1678 - TestContentPage added * Tests added * Tizen Editor and Entry fix * UI Test fix * Android fix for Entry and Editor. * Unit Tests fix. * Android Renderer first try. * MacOS Entry renderer small fix. * UpdateEditable fix. * Android Entry and Editor reduced number of calls to BP. * fix TestAttributes conflicts * Remove keyboard * [macOS] relinquish first responder * [Android] remove call to UpdateCursorSelection * [UWP] fix tabs
Nice work guys but I have small comment regarding to test case you provide to prove this feature is working , I think it will be better if you not just check the flag but implment the feature itseld
test case provide
|
Description of Change
This PR adds the
IsReadOnly
bindable property to theInputView
i.e.Editor
andEntry
controls. Default value isfalse
so this change and usage of this property is backwards compatible.Bugs Fixed
API Changes
Added:
BindableProperty InputView.IsReadOnlyProperty;
Changed:
Behavioral Changes
Supported Platforms
PR Checklist
Remark
There was a section "Implications for CSS", can I get more info about that, is there any way for me to implement that also.