Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Button order on native.showAlert("title", "message", {"OK","Cancel"})
Started by Milner99 Jun 01 2018 06:39 AM

14 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Milner99

[GLOBAL: userInfoPane.html]
Milner99
  • Enthusiast

  • 74 posts
  • Corona SDK

Hi all,

 

Seeing a strange ordering on buttons using native.showAlert(...)

 

See attached image. Any thoughts?

 

Thanks all

Attached Files



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

The macOS naturally shows dialog box buttons in reverse order. This is normal behavior.

 

Rob



[TOPIC: post.html]
#3

Milner99

[GLOBAL: userInfoPane.html]
Milner99
  • Enthusiast

  • 74 posts
  • Corona SDK

Thanks for confirming Rob.



[TOPIC: post.html]
#4

bjoern

[GLOBAL: userInfoPane.html]
bjoern
  • Enthusiast

  • 74 posts
  • Corona SDK

I'm picking this up, because I noticed an issue with the button order on Android 8:

native.showAlert ("Title", "Message", { "Button1", "Button2", "Button3" }, onComplete)

This will result in the following quite random order on Android 8 (can't test other versions at the moment):

Button2
Button3
Button1

 

I am using Build 3308.

 

Best regards!



[TOPIC: post.html]
#5

Milner99

[GLOBAL: userInfoPane.html]
Milner99
  • Enthusiast

  • 74 posts
  • Corona SDK

Glad it’s not just me. Seeing similar, thought I was going mad. Can we get a fix for this? Or a timeline?

[TOPIC: post.html]
#6

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,291 posts
  • Corona SDK

Chinning in unasked, but I don't think Corona will change this.  It would change an existing feature upon which others may depend, and it is relatively low priority compared to big ticket items and ANRs, continuing GDPR changes, etc.

 

You can fix this yourself  by over-ridding the native.showAlert call.  I'll post a solution for you in a few minutes.



[TOPIC: post.html]
#7

Milner99

[GLOBAL: userInfoPane.html]
Milner99
  • Enthusiast

  • 74 posts
  • Corona SDK

Ok thanks.

[TOPIC: post.html]
#8

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,291 posts
  • Corona SDK

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/06/override_showAlert.zip

 

 

1. Decide the behavior you want.

 

2. Test on all targets and see what the default is.

 

3. Modify the code I provided to override behavior for those platforms that do not behave as you want them to.

 

Currently only modifying for Mac OSX, but I think Windows also reverses the label list, so you probably want to reverse it automatically too.

 

4. Re-test.

 

5. Done forever.



[TOPIC: post.html]
#9

bjoern

[GLOBAL: userInfoPane.html]
bjoern
  • Enthusiast

  • 74 posts
  • Corona SDK

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/06/override_showAlert.zip

 

 

1. Decide the behavior you want.

 

2. Test on all targets and see what the default is.

 

3. Modify the code I provided to override behavior for those platforms that do not behave as you want them to.

 

4. Re-test.

 

5. Done forever.

 

Thank you very much for your efforts! However, the problem is not that the order is just reversed - the button order is completely messed up on Android. So a potential "Close" button would appear anywhere in the middle.



[TOPIC: post.html]
#10

Milner99

[GLOBAL: userInfoPane.html]
Milner99
  • Enthusiast

  • 74 posts
  • Corona SDK

Yes it’s seemingly random. Almost like it decides at run time, weird.

[TOPIC: post.html]
#11

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

If you do Button1, Button2, and Button3 on Android 8 will Button3 always be the middle button or are you saying "random order" in that it may on one run be first another last, and a third run in the middle?

 

Rob



[TOPIC: post.html]
#12

Milner99

[GLOBAL: userInfoPane.html]
Milner99
  • Enthusiast

  • 74 posts
  • Corona SDK

I’ll do some tests for you, but from memory it’s different most times, impossible to give the user safe guidance on where a button will be.

[TOPIC: post.html]
#13

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,291 posts
  • Corona SDK

Hi. What exact version of Android are you running and what device are you running on?

 

Ah, I missed it.  Android 8?  Is that correct?

 

FWIW, On android 4.4.2, the button order matches the labels order passed in.

 

Here is and updated copy of the fix and an APK built with: 2018.3297

 

Buttons should come out in the order of the numbers in the labels (not the alpha parts):

 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/06/override_showAlert.zip

 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/06/override_showAlert_APK_2018.3297.zip



[TOPIC: post.html]
#14

bjoern

[GLOBAL: userInfoPane.html]
bjoern
  • Enthusiast

  • 74 posts
  • Corona SDK

If you do Button1, Button2, and Button3 on Android 8 will Button3 always be the middle button or are you saying "random order" in that it may on one run be first another last, and a third run in the middle?

 

Rob

 

For me the order is always the same at runtime, but different depending on the number of buttons:

"1", "2" => "2", "1" (horizontal)

"1", "2", "3" => "2", "3", "1" (horizontal)

"1", "2", "3", "4" => "1", "2", "3", "4" (vertical)
"1", "2", "3", "4", "5" => "1", "2", "3", "4", "5" (vertical)

 

So it's seems like the problem is only with less than 4 buttons, when they are displayed horizontal. It seems like the first element is put at the end in this case. However, I can't test how this behaves with other Android versions at the moment.

 

Best regards!



[TOPIC: post.html]
#15

Milner99

[GLOBAL: userInfoPane.html]
Milner99
  • Enthusiast

  • 74 posts
  • Corona SDK

For me the order is always the same at runtime, but different depending on the number of buttons:

"1", "2" => "2", "1" (horizontal)

"1", "2", "3" => "2", "3", "1" (horizontal)

"1", "2", "3", "4" => "1", "2", "3", "4" (vertical)
"1", "2", "3", "4", "5" => "1", "2", "3", "4", "5" (vertical)

 

So it's seems like the problem is only with less than 4 buttons, when they are displayed horizontal. It seems like the first element is put at the end in this case. However, I can't test how this behaves with other Android versions at the moment.

 

Best regards!

 

Not sure it's based on the number of option, it's one of space. On my OnePlus the buttons are always horizontal, on my Moto G5 they are always vertical but always in a different order.

 

The location is defined by the operating system and screen real estate, android tablets will likely always be horizontal (surely?)

 

Not had chance to do my tests but will asap. As you have that code working @bjoern perhaps change 1,2,3 for real world example of wording like: New Game, Save, Reply, Upload and Screenshot




[topic_controls]
[/topic_controls]