B4J Question Wait For either of two events [solved]

Didier9

Well-Known Member
Licensed User
Longtime User
I would like to be able to trigger a Wait For upon either of two events (two button presses in this case).
How can I do that?

Here is what I am trying to do:
Under some circumstance, I need to pop up a panel where the user can make some selections (ComboBoxes), and the panel also has an OK button and a Cancel button. I want to resume at the Wait For when the user clicks either button, and of course I need to know which button was clicked. How can I capture either button being clicked?
 

Didier9

Well-Known Member
Licensed User
Longtime User
Never mind, found the answer (just had a momentary lapse of consciousness)

B4X:
Sub btnOK_Action
  ' do OK stuff
  CallSubDelayed2( Me, "btnPressed", True )
End Sub

Sub btnCancel_Action
  ' do Cancel stuff
  CallSubDelayed2( Me, "btnPressed", False ) 
End Sub

Sub someSub
  ' pop panel with questions and buttons
  Wait For btnPressed( done as Boolean)

Thank you so much for Wait For...
 
Last edited:
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
I would like to be able to trigger a Wait For upon either of two events (two button presses in this case).
How can I do that?

Here is what I am trying to do:
Under some circumstance, I need to pop up a panel where the user can make some selections (ComboBoxes), and the panel also has an OK button and a Cancel button. I want to resume at the Wait For when the user clicks either button, and of course I need to know which button was clicked. How can I capture either button being clicked?
When there're several buttons in a Panel, usually I assign only one Btn Event on each button on Designer view and fill the Tag field with the name button. In program it can be queried which is the pressed button with code like this.
B4X:
Sub Btn_Click

   Dim selbtn as Button= Sender
 
   Select Case True
         Case selbtn.Tag="OK"
 
         Case selbtn.Tag="Cancel"
   End Select
End sub
 
Upvote 0
Top