From 74f93a222bca93010a19b3ba7c5d5e9d4042dfbe Mon Sep 17 00:00:00 2001 From: Jean-Pierre Ledure Date: Thu, 30 Jan 2025 16:56:51 +0100 Subject: [PATCH] ScriptForge (SFWidgets) fix popup menu bugs 1) when in Python the event argument of CreateScriptService('popupmenu', event) is set to None, an error was raised although not justified. 2) when popupmenu.Execute(False) is run and the user clicks outside the popup menu, the doc says a zero-length string should be returned. It retuned 0. No impact on user documentation. Change-Id: I4e1a1372800a728b994813b021f928fcf2b2603c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180960 Reviewed-by: Jean-Pierre Ledure Tested-by: Jenkins --- wizards/source/sfwidgets/SF_PopupMenu.xba | 5 ++++- wizards/source/sfwidgets/SF_Register.xba | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wizards/source/sfwidgets/SF_PopupMenu.xba b/wizards/source/sfwidgets/SF_PopupMenu.xba index 467e3f748776..d4e5c4d3b075 100644 --- a/wizards/source/sfwidgets/SF_PopupMenu.xba +++ b/wizards/source/sfwidgets/SF_PopupMenu.xba @@ -402,7 +402,10 @@ Check: Try: vMenuItem = MenuRoot.Execute(PeerWindow, Rectangle, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT) - If Not ReturnId Then vMenuItem = MenuIdentification.Item(CStr(vMenuItem)) + ' So far, vMenuItem is an Integer. Convert to the item name when relevant + If Not ReturnId Then + If vMenuItem > 0 Then vMenuItem = MenuIdentification.Item(CStr(vMenuItem)) Else vMenuItem = "" + End If Finally: Execute = vMenuItem diff --git a/wizards/source/sfwidgets/SF_Register.xba b/wizards/source/sfwidgets/SF_Register.xba index 99c9dc9d0d8e..84cc19adc88a 100644 --- a/wizards/source/sfwidgets/SF_Register.xba +++ b/wizards/source/sfwidgets/SF_Register.xba @@ -193,7 +193,7 @@ Check: If IsMissing(pvArgs) Or IsEmpty(pvArgs) Then pvArgs = Array() If Not IsArray(pvArgs) Then pvArgs = Array(pvArgs) If UBound(pvArgs) >= 0 Then Event = pvArgs(0) Else Event = Nothing - If IsEmpty(Event) Then Event = Nothing + If IsEmpty(Event) Or IsNull(Event) Then Event = Nothing ' Event can be Null when popup built by Python code If UBound(pvArgs) >= 1 Then X = pvArgs(1) Else X = 0 If UBound(pvArgs) >= 2 Then Y = pvArgs(2) Else Y = 0 If UBound(pvArgs) >= 3 Then SubmenuChar = pvArgs(3) Else SubmenuChar = ""