How to detect which button was pressed in MessageBox.confirm

How to detect which button was pressed in MessageBox.confirm

I want to use MessageBox.confirm to confirm a user action. In the explorer demo there is an example, but it is using the text of the button to determine which one was pressed. I cant do that because my buttons are going to have differrent texts at runtime.

How can I determine if the Okay button or the cancel button was pressed?

Thanks for the help. I struggled with this because I was using MessageBoxEvent
instead of WindowEvent. MessageBoxEvent is said to include a Dialog, but
that was null so I was unable to track down the button.

A nice enhancement might be to include "String buttonId" in MessageBoxEvent,
so I could easily obtain the button that was pressed along with the value of text
in my prompt field. Just a suggestion.