B4J Question ComboBox - How can I tell the use has entered it ?

Gary Miyakawa

Active Member
Licensed User
Longtime User
I've looked thru the members and generated members..

I'd like to know when someone clicks into a combobox...

How would I detect that ?

Thanks,

Gary Miyakawa
 

Daestrum

Expert
Licensed User
Longtime User
B4X:
         Sub comboBox_MouseClicked (EventData As MouseEvent)
                .....
End Sub
Then you can check if comboBox.SelectedIndex <> -1 which means user has chosen something.
To get the item use
B4X:
         comboBox.Items.Get(comboBox.SelectedIndex)
 
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
Thank you for your reply.

ComboBox doesn't have a "MouseClicked" event...

It's only has "SelectedIndexChange" and and "ValueChange"

ChoiceBox has them, but not ComboBox...
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Odd my old program which has the layout made in scene builder containing a combobox , definitely has mouseclicked as an event (but it doesn't show up in the designer > generate members list) just the two you mentioned.
An extract of the code I use
B4X:
    Private textBox1,recCount As TextField
    Private selectButton,fromButton,whatButton,goButton As Button
    Private choiceBox As ComboBox
    Private fromWhere As String
    Private whichSelect As Int

Then further down I use
B4X:
Sub choiceBox_MouseClicked (EventData As MouseEvent)
    If choiceBox.SelectedIndex <> -1 Then
        whatButton.RequestFocus
        choiceBox.Enabled = False
        Select whichSelect
        Case 1:
            fromWhere = choiceBox.Items.Get(choiceBox.SelectedIndex)
        Case 2:
            Dim tmp As String
            tmp = choiceBox.Items.Get(choiceBox.SelectedIndex)

I checked the layout again and it reports the control as a ComboBox.
 
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
Thank you again! Looks like we might have found a bug-a-boo in the Designer side of B4J...

I'll post this on the Bug side and see if Erel has an answer for us.

Cheers,

Gary Miyakawa
 
Upvote 0
Top