Android Question Set font size of text fields in B4XPreferencesDialog

RB Smissaert

Well-Known Member
Licensed User
Longtime User
As mentioned in this post:
The default text size of the text fields in the B4XPreferencesDialog is a bit small, with a default value of 14.

In the above post there is mention of an event to be used to alter this: BeforeDialogDisplayed
This event to is not raised anymore in the latest version of B4XPreferencesDialog.

The only simple way to fix this was to alter the source code of PreferencesDialog.bas:

B4X:
Sub Class_Globals
    Private miTextFieldFontSize As Int = 14 '14 is the default as set by B4XDialog

Public Sub getTextFieldFontSize As Int
    Return miTextFieldFontSize
End Sub

Public Sub setTextFieldFontSize(iFontSize As Int)
    miTextFieldFontSize = iFontSize
End Sub

Public Sub ShowDialog (Data As Map, Yes As Object, Cancel As Object) As ResumableSub

    If CustomListView1.Size = 0 Then
        Dim LastTextField As B4XFloatTextField
        For Each pi As B4XPrefItem In PrefItems
            Dim pnl As B4XView = CreateLayouts(pi)
            CustomListView1.Add (pnl, pi)
            If pnl.GetView(0).Tag Is B4XFloatTextField Then
                Dim tf As B4XFloatTextField = pnl.GetView(0).Tag
                If LastTextField.IsInitialized Then
                    LastTextField.NextField = tf
                End If
                LastTextField = tf
                tf.TextField.TextSize = miTextFieldFontSize 'If not set then this will be default 14

I can't see much wrong with this approach, but as I couldn't see this approach in the forum, I thought I would raise this problem.

RBS
 

walt61

Active Member
Licensed User
Longtime User
I change such fields like this (no need to tweak PreferencesDialog.bas):
B4X:
    prefsDialog.Add...

    Dim rsub As Object = prefsDialog.ShowDialog(prefsMap, "ok", "cancel")

    For i = 0 To (prefsDialog.CustomListView1.Size - 1)
        For Each v As B4XView In prefsDialog.CustomListView1.GetPanel(i).GetAllViewsRecursive
            If v.tag Is B4XFloatTextField Then
...
            End If
        Next
    Next

    Wait For (rsub) Complete (Result As Int)
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I change such fields like this (no need to tweak PreferencesDialog.bas):
B4X:
    prefsDialog.Add...

    Dim rsub As Object = prefsDialog.ShowDialog(prefsMap, "ok", "cancel")

    For i = 0 To (prefsDialog.CustomListView1.Size - 1)
        For Each v As B4XView In prefsDialog.CustomListView1.GetPanel(i).GetAllViewsRecursive
            If v.tag Is B4XFloatTextField Then
...
            End If
        Next
    Next

    Wait For (rsub) Complete (Result As Int)
OK, thanks, will think about going that route, but I guess I will stick with my current solution as it seems a bit neater and simpler.
I need another alteration as I need an options dialog, without the search box, but will post a new question about that.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
OK, thanks, will think about going that route, but I guess I will stick with my current solution as it seems a bit neater and simpler.
I need another alteration as I need an options dialog, without the search box, but will post a new question about that.

RBS
The solution to get that dialog without the search box was very simple:
Just alter the json file and change "type": "Options" to "type": "Short Options".

RBS
 
Upvote 0
Top