There is an Entry field ScannedValue in my Maui application that I want to use for scanning barcodes with a Bluetooth scanner. I'm targeting Android and iOS platform.
The Entry needs to be focused so that the scanner transfers the barcode into that field. However, every time the field gets focused the keyboard automatically opens and I don't want that.
The whole page is basically a (UraniumUI) TabView which fires an event as soon as the selected tab changes. If the new tab is the one responsible for using the bluetooth scanner, the focus should get set on the entry field.
private void TabView_SelectedTabChanged(object sender, UraniumUI.Material.Controls.TabItem e) {
if (e == null)
return;
if (e.Title.Equals(AppResources.UseBarcodeScanner))
{
SetFocus();
}
}
SetFocus looks like this:
private void SetFocus() {
this.ScannedValue.Focus();
this.ScannedValue.IsEnabled = false;
this.ScannedValue.IsEnabled = true;
}
The field gets focused correctly, but the keyboard does not get closed. As you can see I tried to set IsEnabled, but that does not work. I also tried to create an Interface and a KeyboardHelper class as shown in the following question: Need a way to hide soft keyboard in MAUI's Editor / Entry fields
I also tried to use the following methods:
await ScannedValue.HideSoftInputAsync(default);
await ScannedValue.HideKeyboardAsync();
await KeyboardExtensions.HideKeyboardAsync(ScannedValue);
But nothing works. What am I missing here?


Make a .cs file:
internal class CustomEntry : Entry{}
Use AppendToMapping for your EntryHandler
Add it to your XAML:
< controls:CustomEntry/>
This is not the best solution.
First, you will need to add code for IOS, because this is Android only. Second, notice how this is extending a class. If you want to change such properties on the go, you should do quite some work. Third, sometimes it is up the device itself. I have a professional device that is smart enough to not open its soft keyboard on numeric fields, and let you use the hardware keys... unless you tap it.
There are other ways to approach this problem, this is just an idea.