If I understand your question, you can do it either way.
For example, you have a Custom Class which has 2 edit text fields and a label (edit1,edit2 and label1)
Option 1: Write wrapper methods
public Sub setAllControlData(title As String, field1 As String, field2 As String)
label1.Text = title
edit1.Text = field1
edit2.Text = field2
End Sub
public Sub getTitle As String
Return label1.text
End Sub
public Sub getField1 As String
Return edit1.text
End Sub
public Sub getField2 As String
Return edit2.text
End Sub
public Sub setAllFont(tfont As B4XFont,efont As B4XFont)
label1.font = tfont
edit1.Font = efont
edit2.Font = efont
End Sub
Option2 Publically expose the controls
Sub Class_Globals
Public edit1 As B4XView
Public edit2 As B4XView
Public label1 As B4XView
Private mEventName As String 'ignore
Private mCallBack As Object 'ignore
Public mbase As B4XView 'ignore
end sub
Now your code can access each control individually.
Option1.
Advantages
- You can hide the implementation from the rest of the code.
- only one method call required to perform (possibly) complex operations
Disadvantages
- Don't have fine control over the sub controls e.g. you cannot set the font of the 2 edit fields to different things
Option 2
Advantages
- Can access the internal control individually allowing finer control
disadvantages
- Not as easy to change the implementation
- May need multiple calls to perform certain operations e.g. change the font or set the text.
I would say that there isn't a "best" solution. It would seem that most controls provide a blend of both.
As far as fields in the designer go, you need to propagate this information in the DesignerCreateView function.
the lbl object contains the items from the Text Properties section and also the text
Public Sub DesignerCreateView (Base As Object, lbl As Label, Props As Map)
' Create the label and edit controls here
Private tfnt As B4XFont
tfnt = xui.CreateFont(lbl.Text.font,lbl.TextSize/2)
Private efnt As B4XFont
efnt = xui.CreateFont(lbl.Text.font,lbl.TextSize)
' initialise using the label information
setAllFont(tfnt,efnt)
setAllControlData(lbl.text,"","")
end sub
If you are loading a layout with your sub controls then it is slightly more complicated but the same method applies.