forked from LeenkxTeam/LNXSDK
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from lnx.logicnode.lnx_nodes import *
|
|
|
|
|
|
class WebviewOnEventNode(LnxLogicTreeNode):
|
|
"""Triggers when the given WebView fires an event message, load, error, or close"""
|
|
bl_idname = 'LNWebviewOnEventNode'
|
|
bl_label = 'Webview On Event'
|
|
lnx_category = 'Krom Runtime'
|
|
lnx_section = 'webview'
|
|
lnx_version = 1
|
|
|
|
def update_sockets(self, context):
|
|
for o in self.outputs:
|
|
self.outputs.remove(o)
|
|
|
|
self.add_output('LnxNodeSocketAction', 'Out')
|
|
if self.property0 in ('message', 'error'):
|
|
self.add_output('LnxStringSocket', 'Data')
|
|
|
|
property0: HaxeEnumProperty(
|
|
'property0',
|
|
items=[('message', 'On Message', 'Triggered when a message is received'),
|
|
('load', 'On Load', 'Triggered when the page finishes loading'),
|
|
('error', 'On Error', 'Triggered when a load error occurs'),
|
|
('close', 'On Close', 'Triggered when the WebView is closed')],
|
|
name='Event', default='message', update=update_sockets)
|
|
|
|
def lnx_init(self, context):
|
|
self.add_input('LnxIntSocket', 'ID')
|
|
|
|
self.add_output('LnxNodeSocketAction', 'Out')
|
|
self.add_output('LnxStringSocket', 'Data')
|
|
|
|
def draw_buttons(self, context, layout):
|
|
layout.prop(self, 'property0')
|