Unplanned
Last Updated: 10 Apr 2024 14:52 by ADMIN
Remco
Created on: 10 Apr 2024 14:39
Category: Entry
Type: Feature Request
0
Entry: Provide an option to use the Android specific ImeOption attached property

There is android platform specific attached property ImeOption for entry control.

 <Entry x:Name="Default" FontSize="22" Placeholder="Default" Keyboard="Numeric" android:Entry.ImeOptions="Next" />

Please provide an option to use this property for Telerik MAUI RadEntry. 

1 comment
ADMIN
Didi
Posted on: 10 Apr 2024 14:52

Workaround from 8.0.0 Telerik MAUI version:

<VerticalStackLayout>
	<telerik:RadEntry x:Name="entry" Loaded="entry_Loaded" />
</VerticalStackLayout>

 

private void entry_Loaded(object sender, EventArgs e)
{
	var textInput = ChildOfType<RadTextInput>(this.entry);
	if (textInput != null)
	{
		var handler = textInput.Handler;
		if (handler == null)
		{
			textInput.HandlerChanged += this.OnTextInputHandlerChanged;
		}
		else
		{
			this.UpdateNativeElement(handler);
		}
	}
}

private void OnTextInputHandlerChanged(object sender, EventArgs e)
{
	var textInput = (RadTextInput)sender;

	this.UpdateNativeElement(textInput.Handler);

	textInput.HandlerChanged -= this.OnTextInputHandlerChanged;
}

private void UpdateNativeElement(IViewHandler handler)
{
	var nativeEntry = handler.PlatformView as Telerik.Maui.Platform.RadMauiTextInput;
	if (nativeEntry != null)
	{
#if ANDROID
		nativeEntry.ImeOptions = Android.Views.InputMethods.ImeAction.None;
#endif
	}
}

internal static T ChildOfType<T>(View visualElement) where T : View
{
	if (visualElement == null)
	{
		return null;
	}

	foreach (var item in VisualTreeElementExtensions.GetVisualTreeDescendants(visualElement))
	{
		if (item is T targetElement)
		{
			return targetElement;
		}
	}

	return null;
}

Workaround before 8.0.0 Telerik MAUI version:

Subscribe to the HandlerChanged:

<telerik:RadEntry x:Name="telerikEntry" HandlerChanged="TelerikEntry_HandlerChanged"/>

And set the ImeOptions to the native element:

private void TelerikEntry_HandlerChanged(object sender, EventArgs e)
{
    var nativeEntry = this.telerikEntry.Handler.PlatformView as Telerik.Maui.Platform.RadMauiEntry;

    if (nativeEntry != null) 
    {
        nativeEntry.EditText.ImeOptions = Android.Views.InputMethods.ImeAction.None;
    }
}

 

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.