Suppress or intercept Cancel-event in Messagebox2 when back-button is used

moster67

Expert
Licensed User
Longtime User
I don't think this is possible but I thought I would ask anyway :)

Let us say, I have this code (not actual code but it is good as an example):

B4X:
Select Msgbox2("Select option", "My test", "Yes", "Help", "No", "")
    Case DialogResponse.POSITIVE
      ToastMessageShow("YES",False)
   Case DialogResponse.CANCEL
      ToastMessageShow("Show help-info",False)
   Case Else
      ToastMessageShow("No",False)
End Select

Here I want to use the DialogResponse.CANCEL as a Help-button (instead of cancel) and show some information using the ToastMessage. This works if user clicks on Help-button in the Msgbox2. However, if the Msgbox2 is shown and user clicks on Back-button (instead of Help-button), the DialogResponse.CANCEL and its code is being executed nevertheless and Toastmessage is shown. Now, this is what I wanted to avoid i.e. if user clicks on back-button, I wanted that the Msgbox2 would simply close while if user clicks on Help-button, the Toastmessage be shown.

This happens since the Help (=Cancel)-button and the Back-button does the same thing.

I thought I could resolve it by intercepting the back-button in Activity_KeyPress-event and manipulate but it will not be trapped.

I can understand the problem and of course I am using the MsgBox2 not in a proper way but I wanted to try. I could use other Msgboxes posted here in the forum as an alternative but the advantage of the built-in MsgBox2 is that it will take into consideration the layout-style according to which Android-version is running on the phone (for instance using Holo.Light or Dark or old Gingerbread-style).

Any ideas?
 
Top