'Javascript bridge / upcall to JavaFX (via JSObject.setMember() method) breaks when moving class into a package
This is similar to this question, but I believe we are encountering different issues.
Setup:
I have a Kotlin class that interfaces with a TinyMCE instance running in a JavaFX Webview. I am setting up upcalls from Javascript to JavaFX as shown below, in the TinyMCEInterface class:
inner class BridgeObject {
fun setEditorAndSelection(ed : JSObject?) {
editorObj = ed
selectionObj = editorObj?.getMember("selection") as JSObject?
}
fun setInterfaceContent(newContent : String) {
contentProp.value = newContent
}
}
// after WebEngine loads successfully
val bridgeObj : BridgeObject = BridgeObject()
(webEngine.executeScript("window") as JSObject).setMember("bridgeObj", bridgeObj)
I am then calling these methods from Javascript, in TinyMCE setup:
ed.on('init', function() {
ed.setContent(initContent)
window.bridgeObj.setEditorAndSelection(ed)
window.bridgeObj.setInterfaceContent(ed.getContent())
});
ed.on('Change SelectionChange', function(e) {
window.bridgeObj.setInterfaceContent(ed.getContent())
});
Problem:
This works perfectly fine when the TinyMCEInterface class file lies in the root directory of my application (in package com.myself.app). That is, when the file structure looks like this:
com.myself.app/
│
├─ TinyMCEInterface.kt
│
├─ Main.kt
But breaks when I move TinyMCEInterface into a package (in package com.myself.app.somepackage):
com.myself.app/
│
├─ somepackage/
│ ├─ TinyMCEInterface.kt
│
├─ Main.kt
When I say "breaks", there are no errors; the calls to member functions of window.bridgeObj simply do not happen and quietly fail. I am completely bewildered as to how this can be happening.
Thanks in advance for any advice!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
