Does SyncFusion have an alternative to Maui's ContentPage.DisplayPromptAsync
I have a use case where I need to prompt for text input, either single or multi-line.
I've tried DisplayPromptAsync but it has a number of usability issues:
1: Doesn't reliably place focus in the Entry field.
2: Can't be positioned.
3: Doesn't have a default accept/cancel behavior (e.g., Enter and Escape when a keyboard is present)
4: Doesn't support multiple lines.
I've been looking at SfPopup's Layout customization and Modal window support and would like to know if this is a viable approach (e.g., custom layout with either an Entry or Editor control).
If not, are there other approaches I could use?
For single line input, I'd like the Enter key to default to Accept and the Escape key to default to Cancel. For multi-line input, I'm willing to require a touch event on the Accept and Cancel buttons.
FYI: The application targets desktop, iPad, and Android tablets.
Thanks,
Dan.
Hi Daniel Travison,
We have checked the reported query. You can create a custom entry or custom editor to detect keydown events by implementing IKeyboardListener. When press the Enter key you can set Popup IsOpen as false.
We have attached a working sample for your reference. Please have a look at the sample and let us know if you have any other queries.
Regards,
Jayashree
Attachment: MAUIPopup_2c773076.zip
The IKeyboardListener is a nice idea but I will research other approaches so I don't have to take a dependency on the community toolkit. My popup usage is in my shared control assembly and most of my projects don't need a community toolkit dependency. Perhaps this is something SyncFusion could consider investing in.
However, setting focus is still an issue.
The only solution I have found is what I consider a hack. I created ContentView to contain the entry/editor control and dispatch a call to set focus in the first call to OnChildAdded.
Perhaps a property to set focus to the header or footer would be a viable alternative.
protected override void OnChildAdded(Element child)
{
if (!_focused)
{
_focused = true;
Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(100), () =>
{
this.Focus();
});
}
base.OnChildAdded(child);
}
Hi Daniel Travison,
We would like to let you know that we already have SfPopup component in .NET MAUI platform. We suggest you use our SfPopup control to achieve requirements.
Getting Started with .NET MAUI Popup control | Syncfusion
To detect KeyDown action on Editor or any view, we need to set focus to that view. It is recommended workaround. If view is not in focus, KeyDown event will not invoked.
Please let us know if you have any queries.
- 3 Replies
- 2 Participants
-
DT Daniel Travison
- Jul 20, 2024 08:44 PM UTC
- Jul 29, 2024 01:29 PM UTC