B4J Question b=Sender not working

chuck3e

Active Member
Licensed User
Longtime User
I pass button information from one code module to another:
B4X:
b=Sender
mytag=b.tag
mytext=b.text

This works going from the main module to a second called code module. Both b.text and b.tag show their data correctly.

The second called code module has its own layout and I use the b=Sender logic in it to pass its button info to a third code module, however, the b.text field is ok but the b.tag field is empty. I've checked the id field in the Scene Builder and it has the info in it but it's not showing up in b.tag. What would keep it from showing when it is definitely there?

When I log(b) I get: "b = (Button) Button[id=Button1, styleClass=button], Text: 1. = 2 / 2,"

Also, I found that I can pass info using b.style is this a safe way to pass data?

-C
 

chuck3e

Active Member
Licensed User
Longtime User
I have found a partial answer!

I am able to reference b.tag in the main module and get the correct data but not in the subsequent code modules, however, I am able to get the correct data by referencing b.Id in the subsequent code modules.

So, the question now becomes: Oops! Why does b.tag work in the main module but not in the called code modules.

I have since changed everything to b.Id. The reason I used b.tag in the first place is because the code was cut and pasted from B4A.

I'd still like to know if using b.style is a reasonable way to pass data to called modules through buttons.
 
Upvote 0

chuck3e

Active Member
Licensed User
Longtime User
Erel,
Before I send you something, I may be able to resolve the problem with a couple questions. What is the relationship between b.Tag and b.Id?

I believe Tag is a B4A term and Id is a B4J term but they don't reference the same area in a B4J Scene Builder layout, right? Since B4J's Scene Builder has no such thing as a field called Tag, as far as I can see, I assumed Id was the B4J term for Tag. Now, I don't assume that anymore. I think they are two separate areas in a layout. Am I on track here?

If this is true then Tag, Id, Style, and Text can be used to pass info through a button click.

-C
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…