MsgBox2 and device "Escape"

jpvniekerk

Active Member
Licensed User
Longtime User
I have set up a message as follows:

B4X:
   answ = Msgbox2("ALL DATA SHOWN IN LIST WILL BE EXPORTED", "SELECT EXPORT OPTION", "STANDARD", "SPECIAL", "CANCEL", Null)
   Select answ
      Case DialogResponse.POSITIVE
         ExportStandard
      Case DialogResponse.CANCEL
         ExportSpecial
      Case DialogResponse.NEGATIVE
         Return
   End Select

Now if the message is open and I tap the device's "Escape" button, the program executes ExportSpecial. I want it to execute "Return".

I can overcome this by changing the options to "STANDARD","CANCEL","SPECIAL", but that simply looks unacceptable - the cancel option should be the last (on the right).

I have a subroutine (Activity_KeyPress (KeyCode As Int) As Boolean) in the program that processes the device keypress options. However, when the MsgBox2 is visible, this routine is not raised when I tap "Escape".

Is there any way I can keep my layout as is, but process DialogResponse.NEGATIVE when the user taps the device "Escape" button?
 

jpvniekerk

Active Member
Licensed User
Longtime User
Thanks Erel,

I have to show the Cancel button, but I want it in the third location (right side).
But I also want the device "Escape" button to execute this (third) option (DialogResponse.NEGATIVE), or ignore the "Escape" button completely.
I have not find a way to do either. Is there a way?
 
Upvote 0

jpvniekerk

Active Member
Licensed User
Longtime User
I can understand that.
My concern is that I am now forced to put the cancel button in the center. This is not intuitive from an end-user's perspective. You expect the choices to be stated first and "cancel" last.
Now the message will have options as follows: "CHOICE 1", "CANCEL", "CHOICE 2". As the end user, I find that a very strange (and counter-intuitive) layout.
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
You can't natively change the order of the buttons. You have to do it manually and pay close attention to what code executes with each action. You can capture the back button and have it do what you want.
 
Upvote 0

jpvniekerk

Active Member
Licensed User
Longtime User
JonPM,

I have changed it manually to read "OPTION 1", "OPTION 2", "CANCEL"

I've tried to capture the back button - as mentioned in an earlier post, but when the msgbox2 dialog is open the back button capture sub does not execute - it simply executes "OPTION 2" (DialogResponse.CANCEL).

How can I capture the back button while the msgbox2 dialog is open?
 
Upvote 0

jpvniekerk

Active Member
Licensed User
Longtime User
That is what I am trying to do - use an if statement to see if the back button was pressed - hence my question: How can I capture the back button while the msgbox2 dialog is open?

Maybe I'm a bit dumb - so an example of what you suggest will be appreciated.
 
Upvote 0
Top