Skip to content
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

KeyboardExtensions #1064

Merged
merged 30 commits into from
Apr 14, 2023
Merged

KeyboardExtensions #1064

merged 30 commits into from
Apr 14, 2023

Conversation

PureWeen
Copy link
Contributor

@PureWeen PureWeen commented Mar 5, 2023

Description of Change

Linked Issues

PR Checklist

@brminnick brminnick added pending documentation This feature requires documentation do not merge Do not merge this PR labels Mar 5, 2023
@PureWeen PureWeen changed the title Keyboardmanager KeyboardExtensions Mar 8, 2023
@PureWeen PureWeen requested review from rachelkang and VladislavAntonyuk and removed request for VladislavAntonyuk and rachelkang March 8, 2023 20:23
Copy link
Member

@pictos pictos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've one suggestion

@PureWeen PureWeen requested review from VladislavAntonyuk and brminnick and removed request for VladislavAntonyuk March 9, 2023 17:10
…rdExtensions.shared.cs

Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
PureWeen and others added 2 commits March 9, 2023 11:28
…rdExtensions.shared.cs

Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
@rachelkang
Copy link

Just did some initial testing - ran the sample on Windows and Android, and I'm not sure if the behavior I'm seeing is what we're expecting. (From what I've looked of the code so far (haven't looked at it all yet), this doesn't seem like the intended behavior)

  1. On Windows only, clicking on "Check Keyboard State" would hide the keyboard. I'm not sure why this is happening.
  2. On both Windows (touch mode) and Android, clicking on "Show Keyboard" does successfully show the keyboard. However, it will ALWAYS focus on the first entry, even if the keyboard is already focused and open on another entry. If a control already has focus, I think we should ensure the keyboard will open on that currently focused control. (perhaps even consider making it open on the last focused control if nothing has focus, but I wouldn't be surprised if that actually unleashed a can of worms so maybe not)

@rachelkang
Copy link

  1. This is also happening on iOS, as tested on iPad. So on both Windows and iOS, checking the keyboard state hides the keyboard.

image

  1. On iOS, I'm seeing that while "Hide Keyboard" succeeds to hide the keyboard, the label says "Hide Failed"

image

@JoonghyunCho
Copy link
Member

Added Tizen implementation :)

@PureWeen
Copy link
Contributor Author

PureWeen commented Mar 14, 2023

  1. This is also happening on iOS, as tested on iPad. So on both Windows and iOS, checking the keyboard state hides the keyboard.
image
  1. On iOS, I'm seeing that while "Hide Keyboard" succeeds to hide the keyboard, the label says "Hide Failed"
image

Yea :-/ this is because of the automatically closing TapGesture that gets added to the underlying page. I added some code to remove that tap gesture with a comment here https://github.com/CommunityToolkit/Maui/pull/1064/files#diff-30341c4d54048fcf5f19b98431e6a7fbdf7b21ab928538aa17ff335961a6f667R16-R34.

@pictos
Copy link
Member

pictos commented Mar 21, 2023

@PureWeen is this PR ready for review?

@PureWeen PureWeen marked this pull request as ready for review March 21, 2023 19:58
@jfversluis
Copy link
Member

@pictos marked as ready for review and talked to Shane for the docs, so ready to go!

@jfversluis jfversluis removed do not merge Do not merge this PR pending documentation This feature requires documentation labels Apr 12, 2023
@jfversluis jfversluis merged commit 8a5d550 into CommunityToolkit:main Apr 14, 2023
@al3xmeister
Copy link

How is this meant to be working? The documentation here makes no comment on the token functionality https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.itextinput.keyboard?view=net-maui-7.0
It would appear replicating the sample code with a command executed from the same control, i.e. the return command of an entry throws a : 'Could not resolve type with token in assembly 'CommunityToolkit.Maui.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null')'.
Could someone please update?

@brminnick
Copy link
Collaborator

brminnick commented May 1, 2023

@al3xmeister KeyboardExtensions provides extension methods for ITextInput, for example;

entry.HideKeyboardAsync();

You can find our documentation here: https://learn.microsoft.com/dotnet/communitytoolkit/maui/extensions/keyboard-extensions

And you can read more about the detailed API design and the motivation for adding this feature here: #1055

@al3xmeister
Copy link

al3xmeister commented May 2, 2023

@brminnick Thanks Brandon, but doesnt answer my question. The microsoft documentation makes no reference to a cancellation token. It is a required parameter to HideKeyboardAsync();. I presume it's likely after activity.CurrentFocus?.WindowToken, however you can't access it from the return command of an entry. The sample does it from a button. Could this be updated or revisited?

@jfversluis
Copy link
Member

jfversluis commented May 2, 2023

This video will be made public later today that goes over it: https://youtu.be/bIsGFx7jGcM the sample that goes with it is here: https://github.com/jfversluis/MauiToolkitKeyboardExtensionsSample

If you don't plan on using the cancellation token you can pass in default. Nonetheless, we should fix this up in the docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Add a KeyboardManager for interacting with SoftInputKeyboard device
8 participants