Files
LNXSDK/leenkx/Sources/leenkx/logicnode/WebviewOnEventNode.hx
2026-07-13 15:44:52 -07:00

47 lines
1.0 KiB
Haxe

package leenkx.logicnode;
class WebviewOnEventNode extends LogicNode {
public var property0: String;
var message: String = "";
var error: String = "";
public function new(tree: LogicTree) {
super(tree);
}
override function run(from: Int) {
#if kha_krom
var id: Int = inputs[0].get();
var self = this;
switch (property0) {
case "message":
Krom.webviewSetOnMessage(id, function(msg) { self.onEvent(msg); });
case "load":
Krom.webviewSetOnLoad(id, function() { self.onEvent(null); });
case "error":
Krom.webviewSetOnError(id, function(err) { self.onEvent(err); });
case "close":
Krom.webviewSetOnClose(id, function() { self.onEvent(null); });
}
#end
}
function onEvent(data: String) {
if (data != null) {
if (property0 == "message") this.message = data;
else if (property0 == "error") this.error = data;
}
runOutput(0);
}
override function get(from: Int): Dynamic {
if (from == 1) {
if (property0 == "message") return message;
if (property0 == "error") return error;
}
return null;
}
}