B4J Question How to CSS style the selected/highlighted buttons on jRLDialogsX dialogs?

m4.s

Member
Licensed User
Longtime User
I've searched the forum and haven't seen a way to style the buttons added to this B4J library's displayed dialogs (i.e. when they receive focus), including nothing specific in the author's main thread here:


By default, all such dialog buttons have this light blue styling; which appears to just be the Windows default:


1649725886810.png



But I want to be able to style them to match various module themes in my B4J application.
 

MicroDrie

Well-Known Member
Licensed User
Without a program example it becomes difficult to give a precise answer. There are two options. Whether the interface is made using a form designed in the designer and can be adapted there or, for example, in the listview, the button is added via the program. In that case, this example will work:
B4J jRLDialogsX dialogs colors:
' Add a button to the ListView. The eventname is the same as the button text.
' Any Button property can be set
Sub AddListViewButton(s As String)
    Dim b As Button
    b.Initialize(s)
    b.PrefWidth = BUTTONWIDTH
    b.Id = s
    b.Text = s
'    --- Change the default button colors
    b.Style = "-fx-text-fill:blue;-fx-background-color:yellow;"
'    --- List the style
'    Log(b.Style)
    lvButtons.Items.Add(b)
End Sub[
 
Upvote 0

m4.s

Member
Licensed User
Longtime User
As I originally stated, I'm referring specifically to styling jRLDialogsX dialog buttons.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Based on a partial screen view without any program code use explanation, I have given you a working proof of concept how the color of a dynamically added button can be adjusted to styling jRLDialogsX dialog buttons.

For the display of a button created with the designer in the jRLDialogsX library part you can either adjust in the designer whether you have to use a run-time method to override default designer settings or you can use the supplied program code from the library and adjust it to your preference.

Depending on your circumstances, your wishes and possibilities, and the fact that this library is somewhat dated, using todays [B4X] XUI Views - Cross platform views and dialogs may be more convenient to achieve exactly what you want.
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
As I originally stated, I'm referring specifically to styling jRLDialogsX dialog buttons.
Hi,
have enhanced the library, but not fully tested. The folder examples contains the full example with some dialog button styling.
Give a try = If OK will update the documentation and the post in the B4J Libraries.

B4X:
'Set Button CSS styling
Dlg.OKButtonStyle = "-fx-font-size: 24px;-fx-background-color: indianred;"

'Clear Button CSS styling to use the default
Dlg.OKButtonStyle = ""

1650016743157.png


B4X:
Sub Information_Action
    SetParentWindow
    Dlg.OKButtonText = tfOKButtonText.Text
    Dlg.OKButtonStyle = "-fx-font-size: 24px;-fx-background-color: indianred;"
    Dlg.InformationDialog("InformationDialog Title", "Header", "Content")
End Sub

Sub Warning_Action
    SetParentWindow
    Dlg.OKButtonText = tfOKButtonText.Text
    Dlg.OKButtonStyle = ""
    Dlg.WarningDialog("WarningDialog Title", "Header", "Content")
End Sub

Sub Confirmation_Action
    SetParentWindow
    Dlg.OKButtonText = tfOKButtonText.Text
    Dlg.OKButtonStyle = "-fx-font-size: 24px;-fx-background-color: green;"
    Dlg.CancelButtonText = tfCancelButtonText.Text
    Dlg.CancelButtonStyle = "-fx-font-size: 24px;-fx-background-color: red;"
    taDialogResult.Text = Dlg.ConfirmationDialog("ConfirmationDialog Title", "Header", "Content")
End Sub

Sub YesNoCancel_Action
    SetParentWindow
    Dlg.YesButtonText = tfYESButtonText.Text
    Dlg.YesButtonStyle = "-fx-font-size: 24px;-fx-background-color: green;"
    Dlg.NoButtonText = tfNOButtonText.Text
    Dlg.NoButtonStyle = "-fx-font-size: 24px;-fx-background-color: red;"
    Dlg.CancelButtonText = tfCancelButtonText.Text
    Dlg.CancelButtonStyle = "-fx-font-size: 24px;-fx-background-color: blue;"
    taDialogResult.Text = Dlg.YesNoCancelDialog("YesNoCancelDialog Title", "Header", "Content")
End Sub
 

Attachments

  • jRLDialogsX-188.zip
    118 KB · Views: 48
Upvote 0
Top