Hello,
If possible to add to it an 'undo' menu item.
Yes, you can create a EditorHandler and add CustomSelectionActionModeCallback
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
{
#if ANDROID
handler.PlatformView.CustomSelectionActionModeCallback = new MyCustomSelectionActionModelCallBack();
#endif
});
Next, please create class called MyCustomSelectionActionModelCallBack.cs
. Then you can add menu in the OnCreateActionMode
and handle the undo menu click event in the OnActionItemClicked
method.
#if ANDROID
internal class MyCustomSelectionActionModelCallBack : Java.Lang.Object, ActionMode.ICallback
{
public bool OnActionItemClicked(ActionMode? mode, IMenuItem? item)
{
if(item.ItemId ==10086)
{
//handle your undo operation
}
return false;
}
public bool OnCreateActionMode(ActionMode? mode, IMenu? menu)
{
//add undo Menu
menu.Add(0, 10086, 0, "Undo");
return true;
}
public void OnDestroyActionMode(ActionMode? mode)
{
}
public bool OnPrepareActionMode(ActionMode? mode, IMenu? menu)
{
return false;
}
}
#endif
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.