TomGrill / gdx-dialogs-app

1 stars 2 forks source link

native iOS button dialog bold selection #1

Closed kismosis closed 7 years ago

kismosis commented 8 years ago

on 2 button dialog, button on left is always bold. if you typically use this for the cancel button it will be bold, which highlights the 'wrong' action you generally want the user to take. Can you make the bold button selectable? or leave the right button as the bold button (instead of flip it in the code which you do).

TomGrill commented 8 years ago

You cannot change the bold button in the current version. What you can do is flipping as you mentioned.

I will create an feature issue on the project: https://github.com/TomGrill/gdx-dialogs/issues/4

Thing is the current version uses deprecated classes and methods. So the replacements might not allow this feature. We will see when I have time for updating the code.

kismosis commented 8 years ago

It doesn't help just flipping the strings on the buttons and tried quickly hacking the iOS 8 UIAlertController as a custom button by modifying the IOSGDXButtonDialog, but still couldn't get the bold to change. i did it like this;

    alertView = new UIAlertController(title, message, UIAlertControllerStyle.Alert);

            UIAlertAction defAction=new UIAlertAction((String)labels.get(0),UIAlertActionStyle.Cancel,new VoidBlock1<UIAlertAction>() {
                @Override
                public void invoke(UIAlertAction a) {
                    performClickOnButton(0);
                }
            });
            UIAlertAction defAction2=new UIAlertAction((String)labels.get(1),UIAlertActionStyle.Default,new VoidBlock1<UIAlertAction>() {
                @Override
                public void invoke(UIAlertAction a) {
                    performClickOnButton(1);
                }
            });

            alertView.addAction(defAction);
            alertView.addAction(defAction2);

and instead of show/hide:

    ((IOSApplication) Gdx.app).getUIWindow().getRootViewController().presentViewController(alertView, true, null);

    ((IOSApplication) Gdx.app).getUIWindow().getRootViewController().dismissViewController(true, null);

unfortunately, if you flip the UIAlertActionStyle.Cancel/Default in the actions, the buttons change position and alertView.setPreferredAction(action) doesn't seem to be bound.

After a bit of searching, seems like Apple don't really want you to change the bold/position of buttons. Looks like it is possible, but needs some customization work.

cnnranderson commented 8 years ago

To go into a bit more detail why this is necessary (More so for the fact of making sure the right button text is bold) is just to follow iOS design spec. The right option, typically closest to a user's thumb for right handed users, is the "safe" or "guided" option. It's not safe to assume that the cancel choice will always be on the left. Good example being: http://i.imgur.com/rlt89D1.png where the "guided" choice is cancel, because choosing settings can be considered "destructive" by leaving your app and changing a privacy setting.

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Alerts.html

You'll see here how they describe the situation with two buttons.

The same can be said for dialogs on Android devices running Lollipop, given the material design spec.