Back command is handled with setBackCommand(). You can use
setDefaultDisposeWhenPointerOutOfBounds()
or setDisposeWhenPointerOutOfBounds() for the clicking outside.
Command backCommand = new Command("Back");
alertDialog.setBackCommand(backCommand);
Notice the command doesn't need to invoke dispose or anything. Commands
implicitly dispose the dialog by default.
On Thursday, August 27, 2020 at 9:28:25 PM UTC+3 P5music wrote:
> My app features a popup menu (contextual menu) on certain elements.
>
> I create this dialog (just some options are in the code snippet below):
>
> public static String openContextualMenu()
> {
>
> Dialog alertDialog = new Dialog();
> alertDialog.setLayout(BoxLayout.y());
>
> Button editCommandButton=new Button(new Command(stringEdit));
> Button deleteCommandButton=new Button(new Command(stringDelete));
> Button exportCommandButton=new Button(new Command(stringExport));
>
>
> alertDialog.add(editCommandButton).add(deleteCommandButton).add(exportCommandButton);
>
> Command commandResult=alertDialog.showDialog();
> String result=commandResult.getCommandName();
> return result;
> }
>
> I think this is the right way to create a popup menu in Codename, isn't it?
>
> However I would like to handle the case when the user dismiss the dialog
> with the back button or tapping outside. Is it possible? This could be
> useful also for other dialogs of my app.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/86fd4e43-4c05-4097-947d-98ed5c70bdcfn%40googlegroups.com.