B4J Question How do I retrieve a BBLabel/BBCodeView From a B4XView

MrKim

Well-Known Member
Licensed User
Longtime User
I had this all working fine with a TextArea but like the features of BBLabel/BBCodeViews so I decided to switch. Also, I am really trying to wrap my head around this B4X multiple platform thing but having a hard time. I don't really understand how all of the pieces fit together so it is hard for me to deduce what to do. If I am missing a video or a schematic or lesson that explains it all I would love to know where it/they are.
1585818498867.png


I am loading a bunch of BBLabel/BBCodeViews into customlistview.
so when the user clicks on the selected item I need to retrieve the BBLabel/BBCodeViews

B4X:
    Sub Process_Globals
        Private DandDCtl  As BBLabel
.
.
.
Sub AnotherSub()

A Loop
    Dim P As B4XView = xui.CreatePanel("UnschOPs"), TE As BCTextEngine
    P.LoadLayout("BBLabel")   'Contains ONE 'BBLabel' called 'UnschOPs'
    UnschOPs.Text = "[Color=#ff0000][b][u]" & Crsr.GetString("Os_JobNum") & "[/u][/b][/Color]" & " / " & "[Color=#00ff00][b][u]" & Crsr.GetString("Os_ReleaseNum") & "[/u][/b][/Color]" & " Op " & "[Color=#0000ff][b][u]" & Crsr.GetString("Os_SeqNum") & "[/u][/b][/Color]"
    DandD1.MakeDragSource(UnschOPs.mBase, "DandD1")
    UnSchedOpsList.Add(P, P)   'UnSchedOpsList is a customlistview
    .
    '
    '
End of Loop
End Sub
    Sub UnSchedOpsList_ItemClick (Index As Int, Value As Object)

        Dim P As B4XView = xui.CreatePanel("UnschOPs") ' OR' 'Dim P As B4XView tried both
        P = Value    'this works
        DandDCtl = P.GetView(0)   'this doesn't

The result is:
1585818498867.png

And the code doesn't work.
I kind of understand because it is not a view, But I don't know the syntax to retrieve it.

Thanks for your help
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
 UnschOPs.Text = "[Color=#ff0000][b][u]" & Crsr.GetString("Os_JobNum") & "[/u][/b][/Color]" & " / " & "[Color=#00ff00][b][u]" & Crsr.GetString("Os_ReleaseNum") & "[/u][/b][/Color]" & " Op " & "[Color=#0000ff][b][u]" & Crsr.GetString("Os_SeqNum") & "[/u][/b][/Color]"
Not good... You should use smart strings: [B4X] Smart String Literal
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
B4X:
UnschOPs.Text = "[Color=#ff0000][b][u]" & Crsr.GetString("Os_JobNum") & "[/u][/b][/Color]" & " / " & "[Color=#00ff00][b][u]" & Crsr.GetString("Os_ReleaseNum") & "[/u][/b][/Color]" & " Op " & "[Color=#0000ff][b][u]" & Crsr.GetString("Os_SeqNum") & "[/u][/b][/Color]"
Not good... You should use smart strings: [B4X] Smart String Literal
OK, done:
B4X:
    UnschOPs.Text = ScheduleMod.CheckForLate(Crsr.GetString("Os_StartbyDate"), 3) & $"  [Color=blue][b][u]"$ & Crsr.GetString("Os_JobNum") & $"[/u][/b][/Color] / [Color=black][b][u]"$ & Crsr.GetString("Os_ReleaseNum") & $"[/u][/b][/Color] Op [Color=#0000ff][b][u]"$ & Crsr.GetString("Os_SeqNum") & $"[/u][/b][/Color]"$

But how does that help me get a reference to BBLabel?
I am looking at xulihangs link above but that is retrieving the Tag! Are you telling me the tag holds the referenc! The part I left out of my code above is that I am setting the tag property of P to a MAP! I found it didn't work unless I set P.Tag AFTER
B4X:
UnSchedOpsList.Add(P, P)
is that why it is failing?
This would make sense. Here is the actual code:
B4X:
    UnschOPs.Text = ScheduleMod.CheckForLate(Crsr.GetString("Os_StartbyDate"), 3) & $"  [Color=blue][b][u]"$ & Crsr.GetString("Os_JobNum") & $"[/u][/b][/Color] / [Color=black][b][u]"$ & Crsr.GetString("Os_ReleaseNum") & $"[/u][/b][/Color] Op [Color=#0000ff][b][u]"$ & Crsr.GetString("Os_SeqNum") & $"[/u][/b][/Color]"$
    DandD1.MakeDragSource(UnschOPs.mBase, "DandD1")
    'UnSchedOpsList.Add(P, DT & "  " & Crsr.GetString("Os_JobNum") & "/" & Crsr.GetString("Os_ReleaseNum") & " Op " & Crsr.GetString("Os_SeqNum"))
    UnSchedOpsList.Add(P, P)
    UnschOPs.mBase.Tag = Crsr.GetInt("Os_ID")
    P.Tag = M
'
It was:
B4X:
    UnschOPs.mBase.Tag = Crsr.GetInt("Os_ID")
    P.Tag = M
'    UnschOPs.Text = ScheduleMod.CheckForLate(Crsr.GetString("Os_StartbyDate"), 3) & $"  [Color=blue][b][u]"$ & Crsr.GetString("Os_JobNum") & $"[/u][/b][/Color] / [Color=black][b][u]"$ & Crsr.GetString("Os_ReleaseNum") & $"[/u][/b][/Color] Op [Color=#0000ff][b][u]"$ & Crsr.GetString("Os_SeqNum") & $"[/u][/b][/Color]"$
    DandD1.MakeDragSource(UnschOPs.mBase, "DandD1")
    'UnSchedOpsList.Add(P, DT & "  " & Crsr.GetString("Os_JobNum") & "/" & Crsr.GetString("Os_ReleaseNum") & " Op " & Crsr.GetString("Os_SeqNum"))
    UnSchedOpsList.Add(P, P)
But when I did that I found I couldn't get the MAP. (M is the MAP)

 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't assign a value BBLabal.mBase.Tag. This tag is used by (most) custom views to get a reference to the custom view class.
Use BBLabel.Tag. This is your placeholder.

When you have a view that is "actually" a custom view you can get the custom view with:
B4X:
Dim BBLabel1 As BBLabel = SomeViewYouGotFromCustomListView.Tag
Dim ValueYouStored As Map = BBLabel1.Tag
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Don't assign a value BBLabal.mBase.Tag. This tag is used by (most) custom views to get a reference to the custom view class.
Use BBLabel.Tag. This is your placeholder.

When you have a view that is "actually" a custom view you can get the custom view with:
B4X:
Dim BBLabel1 As BBLabel = SomeViewYouGotFromCustomListView.Tag
Dim ValueYouStored As Map = BBLabel1.Tag
Thanks, interesting, Of course that was my first choice I used the mBase Tag because there was no BBLabal tag in the list. I closed the code, shut down my computer completely for the first time in a couple of weeks, opened it back up and there it was! BBLabal.Tag! Gotta love windows.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Don't assign a value BBLabal.mBase.Tag. This tag is used by (most) custom views to get a reference to the custom view class.
Use BBLabel.Tag. This is your placeholder.

When you have a view that is "actually" a custom view you can get the custom view with:
B4X:
Dim BBLabel1 As BBLabel = SomeViewYouGotFromCustomListView.Tag
Dim ValueYouStored As Map = BBLabel1.Tag
Then shouldn't the mBase tag be read only? Us mortals have enough trouble trying to remember what we CAN do. If I have to try and remember what I CAN'T I am doomed.:p
 
Upvote 0
Top