Dialog.show() doesn't get dismissed when I hit the back button

77 views
Skip to first unread message

Miguel Munoz

unread,
Jun 2, 2016, 1:56:26 AM6/2/16
to CodenameOne Discussions
I created a dialog using one of the Dialog.show() methods, and I discovered that my Android's back button doesn't dismiss the dialog. This breaks the convention of the back button, which should always dismiss a dialog. Your API doesn't even specify what the return value should be when the back button is pressed. Was this an oversight? Or is this by design? Is there a way to get the back button to work?

The method was Dialog.show(String title, String text, Command[] cmds, int type, Image icon, long timeout).

I built this on Mac OSX 10.11.5, and saw it on the Simulator and an Android Moto E (2nd Generation) running Android 5.1.

Shai Almog

unread,
Jun 2, 2016, 2:26:21 AM6/2/16
to CodenameOne Discussions
I think we need to set these dialogs to dispose when the pointer is out of bounds. The Dialog in Codename One is a separate Form so the back arrow has nothing to do with it.
However, if a user taps outside of the dialog it should be like pressing cancel.

Please file an RFE we'll look into it: https://www.codenameone.com/blog/issue-submission-guideline.html

Carlos Verdier

unread,
Jun 2, 2016, 6:40:04 AM6/2/16
to CodenameOne Discussions
The workaround for me is to use showPopupDialog, which can be disposed with back button. I styled it to avoid the default popup design.

Carlos Verdier

unread,
Jun 2, 2016, 7:20:23 AM6/2/16
to CodenameOne Discussions
This also works, so no need for popup dialogs

        dialog.setBackCommand(new Command("") {
            @Override
            public void actionPerformed(ActionEvent evt) {
                dialog.dispose();
            }            
        });        




On Thursday, June 2, 2016 at 12:40:04 PM UTC+2, Carlos Verdier wrote:
The workaround for me is to use showPopupDialog, which can be disposed with back button. I styled it to avoid the default popup design.

On Thursday, June 2, 2016 at 7:56:26 AM UTC+2, Miguel Munoz wrote:
I created a dialog using one of the Dialog.show() methods, and I discovered that my Android's back button doesn't dismiss the dialog. This breaks the convention of the back button, which should always dismiss a dialog. Your API doesn't even specify what the return value should be when the back button is pressed. Was this an oversight? Or is this by design? Is there a way to get the back buttonThis  to work?

Shai Almog

unread,
Jun 3, 2016, 12:52:40 AM6/3/16
to CodenameOne Discussions
Both of those solutions are irrelevant for the static dialog methods.

BTW I would use the new Toast error messages for many of the cases I formerly used dialogs: https://www.codenameone.com/blog/zip-and-toast.html

In the case of a standard dialog instance you can turn on the pointer out of bounds option.

Carlos Verdier

unread,
Jun 3, 2016, 3:18:48 AM6/3/16
to CodenameOne Discussions
True. I din't realize he was talking about the static methods. I'm starting to use Toast to feedback the user. Much better :)

Miguel Munoz

unread,
Jun 3, 2016, 5:56:04 AM6/3/16
to CodenameOne Discussions
The ToastBar looks cool! I tried it and it worked the first time. But not the second. Or the third. It never worked again till I restarted the app.

Miguel Munoz

unread,
Jun 3, 2016, 6:26:21 AM6/3/16
to CodenameOne Discussions


On Wednesday, June 1, 2016 at 11:26:21 PM UTC-7, Shai Almog wrote:
The Dialog in Codename One is a separate Form so the back arrow has nothing to do with it.
This looks like a description of an iOS back button. I'm referring to the back button at the bottom of an Android screen.

Miguel Munoz

unread,
Jun 3, 2016, 6:28:01 AM6/3/16
to CodenameOne Discussions
I submitted an issue to cover this. It's #1793.

Shai Almog

unread,
Jun 4, 2016, 12:59:54 AM6/4/16
to CodenameOne Discussions
If you are referring to the hardware back button then this is a regression. This used to work fine.
Reply all
Reply to author
Forward
0 new messages