B4J Question [Almost SOLVED] How can I customize ControlsUtils notification text font

Star-Dust

Expert
Licensed User
Longtime User
I need to enlarge the font size of the notification message. I don't know how to access the Style Sheet properties of the text.
Should I create a 'notificationpopup.css' file?


B4X:
Private Noty As ControlsUtils
....
Noty.ShowNotification3(Text,Title,Noty.ICON_INFORMATION,Null,"CENTER",10000)
 

Star-Dust

Expert
Licensed User
Longtime User
Currently I have solved this. I created a new invisible form, where I inserted my StyleSheet. I hooked the notification to this Form.
I'm not sure it's the cleanest solution

B4X:
formapp.Initialize("",1,1)
formapp.SetFormStyle("UNDECORATED")
formapp.Stylesheets.Add(File.GetUri(File.DirAssets, "notificationpopup.css"))  
formapp.Show

B4X:
Noty.ShowNotification3(Text,Title,Noty.ICON_INFORMATION, formapp,"CENTER",3000)
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Look here which uses external CSS file.

Note: To change both title and label, keep the order in the external CSS file.
Tested with:
CSS:
.notification-bar > .pane {
    -fx-background-color: red !important;
    -fx-padding: 10 10 10 10 !important;
}

.notification-bar > .pane .label {
    -fx-font-size: 1.333em    !important;
    -fx-text-fill: blue    !important;
    -fx-alignment: top-left    !important;
    -fx-font-weight: 400    !important;
}

.notification-bar > .pane .title {
    -fx-font-size: 2.0em    !important;
    -fx-text-fill: white    !important;
    -fx-font-weight: bold    !important;
}

1660639035011.png


B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
    Private noty As ControlsUtils    'Lib jControlsFX
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Styles.css"))
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    Button1_Click
End Sub

Private Sub Button1_Click
    noty.ShowNotification3("Title","Text",noty.ICON_INFORMATION,Null,"CENTER",2000)
End Sub
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Look here which uses external CSS file.

Note: To change both title and label, keep the order in the external CSS file.
Tested with:
CSS:
.notification-bar > .pane {
    -fx-background-color: red !important;
    -fx-padding: 10 10 10 10 !important;
}

.notification-bar > .pane .label {
    -fx-font-size: 1.333em    !important;
    -fx-text-fill: blue    !important;
    -fx-alignment: top-left    !important;
    -fx-font-weight: 400    !important;
}

.notification-bar > .pane .title {
    -fx-font-size: 2.0em    !important;
    -fx-text-fill: white    !important;
    -fx-font-weight: bold    !important;
}

View attachment 132602

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
    Private noty As ControlsUtils    'Lib jControlsFX
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Styles.css"))
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    Button1_Click
End Sub

Private Sub Button1_Click
    noty.ShowNotification3("Title","Text",noty.ICON_INFORMATION,Null,"CENTER",2000)
End Sub
Unfortunately it did not give me the desired result.
I only have to change the size of the text or title, I don't want to affect all the views of the main form.
For this reason I have created a support form
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
OK - then just another idea to close off for me = adding and clearing external stylesheet(s) when calling shownotification.
In addition could use more external stylesheets = styles,css (as previous), styletitle.css, styletext,css

So something like:
B4X:
Private Sub Button1_Click
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Styles.css"))
    noty.ShowNotification3("Title","Text",noty.ICON_INFORMATION,Null,"CENTER", 2000)
    MainForm.Stylesheets.Clear
End Sub

Private Sub Button2_Click
    'Default
    MainForm.Stylesheets.Clear
    noty.ShowNotification3("Title 2","Text 2",noty.ICON_INFORMATION,Null,"CENTER", 2000)
End Sub
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
OK - then just another idea to close off for me = adding and clearing external stylesheet(s) when calling shownotification.
In addition could use more external stylesheets = styles,css (as previous), styletitle.css, styletext,css

So something like:
B4X:
Private Sub Button1_Click
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "Styles.css"))
    noty.ShowNotification3("Title","Text",noty.ICON_INFORMATION,Null,"CENTER", 2000)
    MainForm.Stylesheets.Clear
End Sub

Private Sub Button2_Click
    'Default
    MainForm.Stylesheets.Clear
    noty.ShowNotification3("Title 2","Text 2",noty.ICON_INFORMATION,Null,"CENTER", 2000)
End Sub
thank's
 
Upvote 0
Top