Bug 27613 - Prevent Entry SoftKeyboard from Showing
Summary: Prevent Entry SoftKeyboard from Showing
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.4
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-03 15:39 UTC by Jon Douglas [MSFT]
Modified: 2016-04-08 19:33 UTC (History)
5 users (show)

Tags: android functional entry ac
Is this bug a regression?: ---
Last known good build:


Attachments
Reproduction (3.91 MB, application/zip)
2015-03-03 15:39 UTC, Jon Douglas [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description Jon Douglas [MSFT] 2015-03-03 15:39:48 UTC
Created attachment 10134 [details]
Reproduction

*Customer Description
I am programmatically entering text into a bunch of Entry controls in a ContentPage. I don't want the keyboard to show since the user isn't supposed to type into them - the text comes from a different async service. But I do want the blinking cursor to show as visual feedback.

*Possible Issues

It seems that by default the OnFocusChangeRequested implementation based on dotPeek decompilation seems that it will show the keyboard within the Focus() event. Thus overriding it would need to happen and specify that you hide it instead or do nothing.

internal override void OnFocusChangeRequested(object sender, VisualElement.FocusRequestArgs e)
{
bool isFocused = this.Control.IsFocused;
base.OnFocusChangeRequested(sender, e);
if (e.Focus)
{
if (isFocused)
return;
InputMethodManager inputMethodManager = (InputMethodManager) Forms.Context.GetSystemService("input_method");
inputMethodManager.ShowSoftInput((Android.Views.View) this.Control, ShowFlags.Forced);
inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
}
else
{
if (!isFocused)
return;
KeyboardManager.HideKeyboard((Android.Views.View) this.Control);
}
}

However when trying to override

protected override void OnFocusChanged (bool gainFocus, Android.Views.FocusSearchDirection direction, Android.Graphics.Rect previouslyFocusedRect)
{
base.OnFocusChanged (gainFocus, direction, previouslyFocusedRect);
}

It seems it is never actually hit within code when added to an EntryRenderer, and thus not able to intercept the method above.

*Forum

http://forums.xamarin.com/discussion/33034/prevent-entry-soft-keyboard-from-showing-on-android

*Reproduction

Attached as XTest.zip - Displays multiple entry fields calling the .Focus event to which the SoftKeyboard displays even when trying to force it to hide.

*Version Information

=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: 205770f1-e611-41a3-925c-7560f7e24eb1
Runtime:
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/jondouglas/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.1.26 (Business Edition)
Hash: 98ee412
Branch: 
Build date: 2015-02-11 04:37:05-0500

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

=== Operating System ===

Mac OS X 10.10.0
Darwin Jons-MacBook-Pro.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Jason Smith [MSFT] 2015-05-27 19:28:12 UTC
There is currently no supported method to do this with Xamarin.Forms.
Comment 3 Bryan Hunter 2016-04-08 19:33:44 UTC
Thank you for your report. It appears the custom renderer workaround posted on Forums (http://forums.xamarin.com/discussion/comment/142567/#Comment_142567) addresses the issue. At this time there are no plans to implement changes around this issue.

Warm regards,
Xamarin Forms Team