B4J Question javafx html editor

westereng

Member
Licensed User
The javafx htmleditor that is standard in B4J is pretty capable I can see, after testing with pretty advanced html.

I have a question though.

I want to have my own toolbar in the app and hide the editor toolbar, i found out on the forum, how to hide it.

But can I reach the the inner functions of the editor, so I can send commands for setting fonts, colors, tables etc. from the outside?

I hope I make sencešŸ˜€

/Ronny
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Use OpenJDK 11+:

B4X:
#VirtualMachineArgs: --add-opens javafx.web/javafx.scene.web=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.graphics=ALL-UNNAMED --add-opens javafx.web/com.sun.javafx.webkit=ALL-UNNAMED --add-opens javafx.web/com.sun.javafx.webkit.theme=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.event=ALL-UNNAMED --add-opens javafx.web/com.sun.javafx.webkit.prism=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.perf=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.network=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.plugin=ALL-UNNAMED --add-opens java.xml/org.w3c.dom=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.dom=ALL-UNNAMED --add-opens java.xml/org.w3c.dom.events=ALL-UNNAMED --add-opens java.xml/org.w3c.dom.ranges=ALL-UNNAMED --add-opens java.xml/org.w3c.dom.traversal=ALL-UNNAMED --add-opens java.xml/org.w3c.dom.views=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.network.about=ALL-UNNAMED --add-opens javafx.web/com.sun.webkit.network.data=ALL-UNNAMED
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI 
    Private Button1 As B4XView
    Private HTMLEditor1 As HTMLEditor
    Private WebPage As JavaObject
    Private HtmlEditorCommand As JavaObject
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    Dim jo As JavaObject = HTMLEditor1
    Dim r As Reflector
    r.Target = jo.RunMethod("getSkin", Null)
    WebPage = r.GetField("webPage")
    HtmlEditorCommand.InitializeStatic("javafx.scene.web.HTMLEditorSkin.Command")
End Sub

Sub Button1_Click
    ExecuteCommand("BOLD", Null)
    ExecuteCommand("FOREGROUND_COLOR", CSSUtils.ColorToHex(fx.Colors.From32Bit(xui.Color_Blue)))
    
End Sub

Sub ExecuteCommand (Command As String, Value As Object)
    WebPage.RunMethod("executeCommand", Array(HtmlEditorCommand.GetFieldJO(Command).RunMethod("getCommand", Null), Value))
End Sub

Commands: https://docs.oracle.com/javase/9/docs/api/index.html?javafx/scene/web/HTMLEditorSkin.html
 
Upvote 0
Top