B4J Question New to B4J and stuck with a ComboBox problem

GarryP64

Member
I am trying to re-create a program I wrote a long time ago on VB6 to control my home brew system. It communicates to a board I repurposed that had a serial port and A/D converter. This my first B4J program so I 'borrowed' the B4J-Chat (posted by Erel in November 2013) to get started.

My problem seems so simple but I am stuck. The ComboBox does not populate. It seems to work but is empty. It is created with the Visual Designer and the variable is declared but it has the squiggly underline with no explanation to why. It compiles fine. One thing I did see is that the documentation says I do not need to initialize the Combobox if it is created with the Designer, but I get a compile error if it is not.

The whole thing is zipped and attached.

Thanks
Garry
 

Attachments

  • B4J.zip
    225.6 KB · Views: 143

Erel

B4X founder
Staff member
Licensed User
Longtime User
Sub Initialize runs before B4XPage_Created.

cmbPort will only be assigned after the call to Root.LoadLayout("MainPage")
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    sp.Initialize("")
    cmbPort.Items.AddAll(sp.ListPorts)
End Sub

Tip: use the Ctrl + Click comment link at the top to create a zip file with the project.
 
Upvote 0

GarryP64

Member
Thanks for the help and for posting back in 2013. Most of my programming is for circuits I build. That compiler is fare less involved than B4J. I did use B4A a long time ago to use a Droid as a display using Bluetooth.

Now, I am stuck on 'txtInput_Action'. This code is almost all yours. What I tried to do was delete the Global variables for the Button, ComboBox, etc, and use the Designer to make a new layout. I can run what you posted back in 2013 and it runs fine. When I copy your code into mine, it does not work. The 'txtInput_Action' does not appear to trigger. I have tried to fine what 'Action' ctually does but can not find any description. Could you plese tell me what it does and where to find it.

Thanks
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hey
On the designer Right click -> generate, you will see the list of actions the node can do.

It will react to TextChanged, MouseClicked and FocusChanged.
In the past _action reacted to the Enter key but this changed a while ago and it wasn't for all the nodes.

change _action to _focuschanged or move the code to a button and react to the mouseclicked.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…