MsgBox

So how in the world are you supposed to use this?
I need to show a msgbox if the user enters the wrong information, then move to a different view depending on if they OK or CANCEL

But being asynchronous it keeps tooling along, it is stupid (and reckless) to put the app into an infinite loop and let the msgbox event move it ahead
but until I know the “answer” to which button they tapped, the app has to “stop”.

I understand about not blocking the main thread, yada yada… but what is the best/proper way to deal with this?

Take a look in Example Projects\iOS\Declares\iOSAlerts. The code in the “Action msgbox” button and “Tag msgbox” button demonstrates how to pass in a callback method for the action of tapping a button.

Drag it onto your view then use the event to push to a view.

Using the Alert Sheet from the example, I set up my project with a subclass of iOSView that has a ShowMessageBox method and an ActionSheetResult Event Definition. Makes it very easy to handle this type of problem for multiple views. Please note that I assed the MyTag as text variable to the alert sheet class from the example.

In your iOSView subclass, the method you’ll call when you want to show the message box:

[code]Sub ShowMessageBox(boxTag as text, theMessage as text, buttons() as text, cancelButtonName as text=“Cancel”)
if buttons=nil or UBound(buttons)=-1 then
Return
end if

dim xx as new AlertSheet

xx.MyTag = boxTag
xx.CancelButton = cancelButtonName
xx.ActionButtons = buttons
xx.Message = theMessage

AddHandler xx.ButtonAction, AddressOf ButtonResult
xx.Show(me)
End Sub
[/code]

Then the ButtonResult private method:

Sub ButtonResult(sender as alertSheet, buttonIndex as integer, cancel as Boolean) if cancel=false then RaiseEvent ActionSheetResult(sender.myTag, buttonIndex) end if End Sub

And the event definition:

Event ActionSheetResult(sheetTag as text, buttonIndex as integer) Sub ()

Now whenever you want to call a message box with a response it’s very simple, you’ll just make sure your view is the iOSView subclass, and then use:

self.ShowMessageBox("someTag","Do you want to do that?",Array("Yes", "Maybe","Sure"))

And then implement the ActionSheetResult with something like:

select case sheetTag case "someTag" select case buttonIndex case 0//yes self.pushTo(someView) case 1//maybe case 2//sure end select end select

To make it a little easier to understand I just made a quick sample project with the subclass from above included:
http://www.oranged.net/extras/EasyMessageBox.xojo_binary_project.zip