I found native JavaFX code how to focus the webview in the HTMLeditor, so I ask anyone of you gurus out there to convert this code to B4J. It would be most useful and great to learn from. How to use it with inline Java code #If JAVA code #End if thanks.
Source webpage can be found >here<
JAVAFX
EDIT: I have updated my post because I turned Erel's code into a library. You can find it in B4j Libraries and Classes.
You can go there directly by clicking >here<
Source webpage can be found >here<
JAVAFX
B4X:
import com.sun.javafx.scene.web.skin.HTMLEditorSkin;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.web.HTMLEditor;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class FocusTest extends Application {
public static void main(final String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
final HTMLEditor editor = new HTMLEditor();
final WebView view = (WebView) ((GridPane)((HTMLEditorSkin)editor.getSkin()).getChildren().get(0)).getChildren().get(2);
primaryStage.setScene(new Scene(editor));
primaryStage.sizeToScene();
primaryStage.show();
Platform.runLater(() -> {
view.fireEvent(new MouseEvent(MouseEvent.MOUSE_PRESSED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false, false, false, false, false, false, false, null));
editor.requestFocus();
view.fireEvent(new MouseEvent(MouseEvent.MOUSE_RELEASED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false, false, false, false, false, false, false, null));
});
}
}
EDIT: I have updated my post because I turned Erel's code into a library. You can find it in B4j Libraries and Classes.
You can go there directly by clicking >here<
Last edited: