Hi, I’ve been working on a extension for libreoffice, using scriptforge, So far it has helped me to build things without taking too long to grok on documentation in different places.
I found something that I’m not understanding: How to bind an action to a button. From the docs it seems that I need to have a macro to be launched from the event.
onhelp = "service:org.fectp.StableHordeForLibreOffice?get_help"
dlg = CreateScriptService(
"NewDialog", "AIHordeOptionsDialog", (47, 10, 265, 206)
)
button_help = dlg.CreateButton("CommandButton1", (23, 15, 13, 10))
button_help.Caption = "?"
button_help.OnKeyPressed = onhelp # <a macro here> This reference does not work
class AiHordeForLibreOffice(unohelper.Base, XJobExecutor, XEventListener):
"""Service that creates images from text. The url to be invoked is:
service:org.fectp.AIHordeForLibreOffice
"""
def trigger(self, args):
print(args)
if args == "create_image":
generate_image(self.desktop, self.context)
if args == "validate_form":
print("validate_event")
if args == "get_help":
print("get_help")
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(
AiHordeForLibreOffice,
LIBREOFFICE_EXTENSION_ID,
("com.sun.star.task.JobExecutor",),
)
g_exportedScripts = (get_help,)
The problem is that I need to have a reference to the running process in order to let it be notified, and I was understanding that a macro is outside the context, and I don’t see how can I pass a reference to the macro. I’m not able either to publish a macro from my extension. in addition, I tried creating a function and using g_exportedScripts
with no luck.
I haven’t found documentation on this particular purpose or a different way to bind an event without a macro to a control with scriptforge.
Basically What I’m doing is running a thread and I want to let the user cancel the thread pushing a button, but I haven’t managed to put a listener. and react inside the same extension.
The only option is to avoid scriptforge and rebuild the dialog? Or is there a choice with scriptforge that I’m maybe missing?