To solve this i made the following (using this (reference that said alexandar) & this):
On MauiProgram add after builder:
builder
.UseMauiCompatibility()
.ConfigureMauiHandlers((handlers) => {
#if ANDROID
handlers.AddCompatibilityRenderer(typeof(yournamespaceofhelper.SoftkeyboardDisabledEntry),typeof(yournamespaceonAndroid.SoftkeyboardDisabledEntryRenderer)); #endif})
2.Create a helper (which it's the one you will use it with disabled keyboard):
public class SoftkeyboardDisabledEntry : Entry
{
}
- On Platforms/Android create the renderer
[assembly: ExportRenderer(typeof(SoftkeyboardDisabledEntry), typeof(SoftkeyboardDisabledEntryRenderer))]
namespace YourAppName.Platforms.Android
{
public class SoftkeyboardDisabledEntryRenderer : EntryRenderer
{
public SoftkeyboardDisabledEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
((SoftkeyboardDisabledEntry)e.NewElement).PropertyChanging += OnPropertyChanging;
}
if (e.OldElement != null)
{
((SoftkeyboardDisabledEntry)e.OldElement).PropertyChanging -= OnPropertyChanging;
}
// Disable the Keyboard on Focus
this.Control.ShowSoftInputOnFocus = false;
}
private void OnPropertyChanging(object sender, PropertyChangingEventArgs propertyChangingEventArgs)
{
// Check if the view is about to get Focus
if (propertyChangingEventArgs.PropertyName == VisualElement.IsFocusedProperty.PropertyName)
{
// incase if the focus was moved from another Entry
// Forcefully dismiss the Keyboard
InputMethodManager imm = (InputMethodManager)this.Context.GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(this.Control.WindowToken, 0);
}
}
}
}
How this work? you will use a custom entry, that everytime you write something on the entry it's get unfocused, doing this, when the property of the entry changes, it will keep what you write on it but dissappear with the focus / unfocus. The big con of this it's that if you use (for example in my case a magnetic card reader) the reader write so fast so the entry get's focused / unfocused and the keyboard appears. working on it to make a delay so the keyboard doesn't show to the user.
Answering the question you said to alexandar, in case you touched the editor, the keyboard will stay hidden
PD: I couldn't find a way to make the code readable so if someone can edit it, it is appreciated