Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[Proposal] SelectAllTextEffect

Open TheCodeTraveler opened this issue 4 years ago • 4 comments

SelectAllTextEffect

  • [x] Proposed
  • [x] Prototype
  • [x] Implementation
    • [x] iOS Support
    • [x] Android Support
    • [x] macOS Support
    • [x] Windows Support
  • [ ] Unit Tests: Not Started
  • [x] Sample
  • [ ] Documentation: Not Started

Summary

Highlights all text when an InputView is selected

Detailed Design

SelectAllTextEffect.shared.cs

public class SelectAllTextEffect : RoutingEffect
{
}

SelectAllTextEffect.android.cs

public class SelectAllTextEffect : PlatformEffect
{
  EditText EditText => (EditText)Control;
  
  protected override void OnAttached() => EditText?.SetSelectAllOnFocus(true);
  
  protected override void OnDetached() => EditText?.SetSelectAllOnFocus(false);
}

SelectAllTextEffect.ios.cs

public class SelectAllTextEffect : PlatformEffect
{
  protected override void OnAttached() => ApplyEffect(true);
  
  protected override void OnDetached() => ApplyEffect(false);
  
  void ApplyEffect(bool apply) => ApplyToControl(Control, apply);

  bool ApplyToControl<T>(T controlType, bool apply) => controlType switch
  {
	UITextField textField => ApplyToUITextField(textField, apply),
	UITextView => ApplyToUITextView(apply),
	_ => throw new NotSupportedException($"Control of type: {controlType?.GetType()?.Name} is not supported by this effect.")
  };
}

Usage Syntax

TheCodeTraveler avatar Sep 26 '21 18:09 TheCodeTraveler

Blocked. Pending the result of https://github.com/CommunityToolkit/Maui/issues/124

TheCodeTraveler avatar Oct 07 '21 20:10 TheCodeTraveler

Will review this point in a .NET MAUI team meeting next week and after that, we can validate this proposal!

jsuarezruiz avatar Nov 04 '21 19:11 jsuarezruiz

I'll use this one to draw the API to implement our Effects as Behavior and after that go through all other Effects and see if it makes sense for all.

As we discussed on the last CommunityStandup

pictos avatar Dec 17 '21 02:12 pictos

Reopening Proposal.

Only Proposals moved to the Closed Project Column and Completed Project Column can be closed.

ghost avatar Jun 01 '22 02:06 ghost

@brminnick, @pictos seems like it can be closed as completed. any objections?

VladislavAntonyuk avatar Mar 01 '23 14:03 VladislavAntonyuk