B4J Question Node, View, B4XView, Control, or some other class?

Heuristx

Member
Licensed User
Which tutorials should I watch or read to understand the difference between Node, B4XView, View, Control and other screen objects and also the behaviour of the global variables that the Visual Designer can generate?

I find some confusing terms. For example, GetAllViewsRecursive is explained as "Returns an iterator that iterates over all the child nodes[...]" - so why is it not called GetAllNodesRecursive?
If I create a new tab page by loading a Layout into a Tab Pane, I cannot use that tab page as the root of nodes, I have to use TabPage.Content. So what is a TabPage? Control? View? But View does not exist in B4J(View is B4I?), it should be B4XView, and that is a construct specific for [Controls|Nodes|Screen objects] that are OS-independent.

I can use the Tag of each screen object created with the Visual Designer to iterate nodes and find my screen object... except a CustomListView. This is a strange one. Automatically, its name is CustomListView1 in the Visual Designer. But in the same Visual Designer, its Type is shown as CustomView, an object that does not exist in code. I can force a CustomListView to behave as a B4X object by saying CustomListView1.AsView, but if I iterate the nodes of the root, all I find is some non-resize panels, so the conversion does not work backwards, so I cannot put a tag to it and find it on a Root Pane.

That leaves the Global variable that I create from the Visual Designer. But that may or may not be the solution.

What if I have a TabPane, I load several TabPages into it, and each TabPage has a CustomListView? Then the global variable would not know which one to refer to. I was thinking that when I load a layout, the global variable points to the newly loaded layout's screen objects, I guess I would have to insert a Sleep(0) after loading the layout. That way I can grab the CustomListView and put it into a real Node's tag. Would that be the intended behaviour?

I realize these are several questions disguised as one, but I don't expect anyone to write an essay about it or answer all. I just wanted to explain why I am confused. My question is still the same: is there a tutorial I can read or watch that would make all these things clear?
 

EnriqueGonzalez

Well-Known Member
Licensed User
Hi!
A control, a view, a node, a b4xview all of them refer to the same thing, from different perspectives.

A node is how javafx calls the any UI element. (Say a button, a label)

A view is how b4a users used to call the same elements,

A b4xview is how we all call the same elements based on the new (2 years old) xui, xuiviews libraries.

Therefore a button is a node and a view and a b4xview, for your own sake, most of the time its best to create them with the VD as a b4xview. As it has extra utilities to make your life easier
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Then the global variable would not know which one to refer to. I
This is correct but this is also a badly implemented interface .

You could for instance use classes to encapsulate the customlistview in its own environment

Or dont use global variables and pull them from their parents using a method like getnode
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
so why is it not called GetAllNodesRecursive?
I understand it may be confusing that a tab doesn't hold the the tabpages but it is true

A tabpane is only a "administrator" for the various pages, it is not a view (b4xview) that holds other views.

The real panes are inside the tabpages that are the ones holding other views

Dont stress over it too much, it is a javafx implementation
 
Upvote 0

Heuristx

Member
Licensed User
Hi!
A control, a view, a node, a b4xview all of them refer to the same thing, from different perspectives.

A node is how javafx calls the any UI element. (Say a button, a label)

A view is how b4a users used to call the same elements,

A b4xview is how we all call the same elements based on the new (2 years old) xui, xuiviews libraries.

Therefore a button is a node and a view and a b4xview, for your own sake, most of the time its best to create them with the VD as a b4xview. As it has extra utilities to make your life easier

Thank you, Enrique. I do use the VD whenever possible, but when you load the same layout several times(like pages in a TabPane), then it gets to coding and recognizing these things.
I'd love to understand, for example, why a TabPage is not a node and so it is not compatible with B4X functions. I guess there are wrapper objects that encapsulate multiple nodes into one object but are not recognizable as Nodes.
 
Upvote 0

Heuristx

Member
Licensed User
This is correct but this is also a badly implemented interface .

You could for instance use classes to encapsulate the customlistview in its own environment

Or dont use global variables and pull them from their parents using a method like getnode

Do you mean put the CustomListView on a pane? Then how do I refer to it in code?
CustomListView is not a Node.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Create a class, say
Tabclvclass

Add global variables: tabpage, customlistview

Initialize and load the visual designer inside that class.

Pseudocode
Public customlistview as b4xview

Sub initialize as tabpage
Tp.loadlayout
Return tp


In your main module,
Dim tcc as tabclvclass
Tcc.customlistview

And so on,

Then you will hold the information on the customlistview for each tabpage.

Unfortunately i am on my cellphone. Later will do an example.
 
Upvote 0

Heuristx

Member
Licensed User
Create a class, say
Tabclvclass

Add global variables: tabpage, customlistview

Initialize and load the visual designer inside that class.

Pseudocode
Public customlistview as b4xview

Sub initialize as tabpage
Tp.loadlayout
Return tp


In your main module,
Dim tcc as tabclvclass
Tcc.customlistview

And so on,

Then you will hold the information on the customlistview for each tabpage.

Unfortunately i am on my cellphone. Later will do an example.

I still don't see how I connect the CustomListView variable in code to the CustomListView in the VD.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
this is how i would do it, but as i was doing it, i think may be a map to hold the information would be enough.
 

Attachments

  • multi_clv.zip
    3.8 KB · Views: 32
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
So it IS the global variable
Right, as you see, you have perfect control on what customlistview is the user interacting with.

you could be as bold as using callsubdelayed to send the customviews events into the main module. but thats another story
 
Upvote 0
Top