| Server IP : 121.121.20.254 / Your IP : 216.73.217.89 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/03/ |
Upload File : |
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<base href="../../../../../">
<noscript><meta http-equiv="refresh" content="0; URL=../../../../../en-US/noscript.html"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SFWidgets.PopupMenu service</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="en-US/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="en-US/text/shared/05/new_help.html"><div></div></a><a class="logo" href="en-US/text/shared/05/new_help.html"><p dir="auto">LibreOffice 24.2 Help</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Module</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contents</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Search in bookmarks for chosen module" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<a name="ScriptForge-sf_popupmenu"></a>
<a name="bm_id501600788076877"></a>
<meta itemprop="keywords" content="PopupMenu service">
<a name="abstract"></a>
<h1 id="bm_id681600788076499" dir="auto">
<a name="PopupMenuService"></a><span class="literal">SFWidgets</span>.<span class="literal">PopupMenu</span> service</h1>
<p id="par_id181600788076612" class="paragraph" dir="auto">The <span class="literal">PopupMenu</span> service can be used to create popup menus that can be associated with events or executed by scripts. This service provides the following capabilities:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id301600788076785" class="listitem" dir="auto">Creation of popup menus with custom entries, checkboxes and radio buttons.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id1001600788076848" class="listitem" dir="auto">Decoration of menu items with icons and tooltips.</p>
</li>
</ul>
<h2 id="hd_id281600788076359" dir="auto">Service invocation</h2>
<p id="par_id141609955500101" class="paragraph" dir="auto">Before using the <span class="literal">PopupMenu</span> service the <span class="literal">ScriptForge</span> library needs to be loaded or imported:</p>
<div class="embedded">
<a name="importLibs"></a>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id901528999850603" dir="auto">• Basic macros require to load <span class="literal">ScriptForge</span> library using the following statement:<br><span class="literal">GlobalScope.BasicLibraries.loadLibrary("ScriptForge")</span><br><br>• Python scripts require an import from <span class="literal">scriptforge</span> module:<br><span class="literal">from scriptforge import CreateScriptService</span>
</p></div>
</div>
<br>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<p id="par_id321614902851541" class="paragraph" dir="auto">The <span class="literal">PopupMenu</span> service can be instantiated in multiple ways. The example below creates a popup menu without associating it with a mouse or application event.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub ShowPopup
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
Dim myPopup As Object
Set myPopup = CreateScriptService("SFWidgets.PopupMenu", , 300, 300)
myPopup.AddItem("Item ~A")
myPopup.AddItem("Item ~B")
vResponse = myPopup.Execute()
MsgBox("Selected item ID: " & vResponse)
myPopup.Dispose()
End Sub
</code></pre></div>
<p id="par_id341636718182262" class="paragraph" dir="auto">Running the <span class="literal">Sub</span> defined above will create a popup menu with two entries in the position X=300 and Y=300 on the screen.</p>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id711636493696169" dir="auto">The prefix <span class="literal">SFWidgets</span> can be suppressed while invoking the <span class="literal">PopupMenu</span> service.</p></div>
</div>
<br>
<p id="par_id851635274721129" class="paragraph" dir="auto">The following example defines a <span class="literal">Sub</span> that can be associated with a mouse event:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub MyPopupClick(Optional poMouseEvent as Object)
Dim myPopup As Object
Set myPopup = CreateScriptService("PopupMenu", poMouseEvent)
' Populate popupmenu with items
Dim vResponse As Variant
vResponse = myPopup.Execute(False)
' Do something based on vResponse
' ...
myPopup.Dispose()
End Sub
</code></pre></div>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id991636718278125" dir="auto">Use the <span class="literal">Dispose</span> method to free resources after executing the popup menu.</p></div>
</div>
<br>
<p id="par_id531636493797707" class="paragraph" dir="auto">It is also possible to associate a popup menu with events triggered by LibreOffice applications, form and dialog controls. Events such as "Mouse button pressed" and "Mouse button released" are commonly associated with popup menus.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub MyPopupClick(Optional poEvent as Object)
Dim myPopup As Object
Set myPopup = CreateScriptService("PopupMenu", poEvent)
' ...
End Sub
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<p id="par_id131635275172617" class="paragraph" dir="auto">The examples above can be written in Python as follows:</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
def show_popup(args=None):
my_popup = CreateScriptService("SFWidgets.PopupMenu", None, 300, 300)
bas = CreateScriptService("Basic")
my_popup.AddItem("Item ~A")
my_popup.AddItem("Item ~B")
response = my_popup.Execute()
bas.MsgBox(f"Selected item ID: {response}")
my_popup.Dispose()
</code></pre></div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
def my_popup_click(poEvent=None):
my_popup = CreateScriptService("SFWidgets.PopupMenu", poEvent)
# Populate popupmenu with items
response = my_popup.Execute()
# Do something based on response
my_popup.Dispose()
</code></pre></div>
<a name="bm_id111614901520029"></a>
<meta itemprop="keywords" content="PopupService service,ShortcutCharacter">
<meta itemprop="keywords" content="PopupService service,SubmenuCharacter">
<h2 id="hd_id711600788076834" dir="auto">Properties</h2>
<a name="properties_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id461600788076917" class="tableheadintable" dir="auto">Name</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id221600788076591" class="tableheadintable" dir="auto">Readonly</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id761600788076328" class="tableheadintable" dir="auto">Type</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id67160078807636" class="tableheadintable" dir="auto">Description</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id941600788076595" class="tablecontentintable" dir="auto">ShortcutCharacter</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id49160078807654" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id961600788076376" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id81600788076419" class="tablecontentintable" dir="auto">Character used to define the access key of a menu item. The default character is <span class="literal">~</span>.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id491600788076621" class="tablecontentintable" dir="auto">SubmenuCharacter</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id311600788076756" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id831600788076785" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id441600788076826" class="tablecontentintable" dir="auto">Character or string that defines how menu items are nested. The default character is <span class="literal">></span>.</p>
</td>
</tr>
</table>
<br>
<h2 id="hd_id181636719707892" dir="auto">Menu and Submenus</h2>
<p id="par_id741636719725402" class="paragraph" dir="auto">To create a popup menu with submenus, use the character defined in the <span class="literal">SubmenuCharacter</span> property while creating the menu entry to define where it will be placed. For instance, consider the following menu/submenu hierarchy.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
' Item A
' Item B > Item B.1
' Item B.2
' ------ (line separator)
' Item C > Item C.1 > Item C.1.1
' Item C.1.2
' Item C > Item C.2 > Item C.2.1
' Item C.2.2
' ------ (line separator)
' Item C.2.3
' Item C.2.4
</code></pre></div>
<p id="par_id211636720111489" class="paragraph" dir="auto">The code below uses the default submenu character <span class="literal">></span> to create the menu/submenu hierarchy defined above:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
myPopup.AddItem("Item A")
myPopup.AddItem("Item B>Item B.1")
myPopup.AddItem("Item B>Item B.2")
myPopup.AddItem("---")
myPopup.AddItem("Item C>Item C.1>Item C.1.1")
myPopup.AddItem("Item C>Item C.1>Item C.1.2")
myPopup.AddItem("Item C>Item C.2>Item C.2.1")
myPopup.AddItem("Item C>Item C.2>Item C.2.2")
myPopup.AddItem("Item C>Item C.2>---")
myPopup.AddItem("Item C>Item C.2>Item C.2.3")
myPopup.AddItem("Item C>Item C.2>Item C.2.4")
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id121636721243578" dir="auto">The string <span class="literal">---</span> is used to define separator lines in menus or submenus.</p></div>
</div>
<br>
<a name="using_icons"></a>
<h2 id="hd_id211636723438558" dir="auto">Using icons</h2>
<p id="par_id981636723485402" class="paragraph" dir="auto">Items in the menu can have icons, which are specified as arguments in the <span class="literal">AddCheckBox</span>, <span class="literal">AddItem</span> and <span class="literal">AddRadioButton</span> methods.</p>
<p id="par_id881636724112434" class="paragraph" dir="auto">All icons available in LibreOffice can be used by specifying their path relative to the folder where icon files are located in the installation folder. Icons are located in the following folder:</p>
<p id="par_id991636724479899" class="paragraph" dir="auto"><span class="input" data-tooltip="Click on text to copy to clipboard">INSTALLDIR/share/config</span></p>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id941636724808906" dir="auto">Use the <span class="literal">InstallFolder</span> property of the <span class="literal">FileSystem</span> service to determine where LibreOffice is installed in your system.</p></div>
</div>
<br>
<p id="par_id201636724575911" class="paragraph" dir="auto">This folder contains a series of ZIP files containing the image files of each available icon set. The images inside these ZIP files are organized into folders. To use an icon, specify the icon file with the path to its location inside the ZIP file.</p>
<p id="par_id641636724972071" class="paragraph" dir="auto">The example below uses the icon "sc_newdoc.svg" that is located inside the "cmd" folder. The forward slash "/" character is used as the path separator regardless of the operating system.</p>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
myMenu.AddItem("Item A", Icon := "cmd/sc_newdoc.svg")
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
myMenu.AddItem("Item A", icon="cmd/sc_newdoc.svg")
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id691636725233961" dir="auto">All icon sets have the same internal structure. The actual icon displayed depends on the icon set currently in use.</p></div>
</div>
<br>
<h2 id="hd_id501582887473754" dir="auto">Methods</h2>
<a name="methods_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="3" class="tableheadcell" dir="auto">
<p id="par_id891611613601554" class="tableheadintable" dir="auto">List of Methods in the PopupMenu Service</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id891611613601556" class="tablecontentintable" dir="auto">
<a target="_top" href="en-US/text/sbasic/shared/03/sf_popupmenu.html#AddCheckBox">AddCheckBox</a><br>
<a target="_top" href="en-US/text/sbasic/shared/03/sf_popupmenu.html#AddItem">AddItem</a>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id541611613601554" class="tablecontentintable" dir="auto">
<a target="_top" href="en-US/text/sbasic/shared/03/sf_popupmenu.html#AddRadioButton">AddRadioButton</a><br><br>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id541611613625804" class="tablecontentintable" dir="auto">
<a target="_top" href="en-US/text/sbasic/shared/03/sf_popupmenu.html#Execute">Execute</a><br><br>
</p>
</td>
</tr>
</table>
<br>
<a name="AddCheckBox"></a>
<a name="bm_id92158919969883"></a>
<meta itemprop="keywords" content="PopupMenu service,AddCheckBox">
<h2 id="hd_id201589199698251" dir="auto">AddCheckBox</h2>
<p id="par_id93158919969864" class="paragraph" dir="auto">Inserts a check box in the popup menu. Returns an integer value that identifies the inserted item.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id821621534014732" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.AddCheckBox(menuitem: str, opt name: str, opt status: bool = False, opt icon: str, opt tooltip: str): int</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id821591631203996" class="paragraph" dir="auto"><span class="emph">menuitem:</span> Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character.</p>
<p id="par_id821591631203116" class="paragraph" dir="auto"><span class="emph">name:</span> String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used.</p>
<p id="par_id821591631203133" class="paragraph" dir="auto"><span class="emph">status:</span> Defines whether the item is selected when the menu is created (Default = <span class="literal">False</span>).</p>
<p id="par_id11636721653313" class="paragraph" dir="auto"><span class="emph">icon:</span> Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used.</p>
<p id="par_id11636721653208" class="paragraph" dir="auto"><span class="emph">tooltip:</span> Text to be displayed as tooltip.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
myPopup.AddCheckBox("Option A", Status := True)
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
my_popup.AddCheckBox("Option A", status=True)
</code></pre></div>
<a name="AddItem"></a>
<a name="bm_id92158919960353"></a>
<meta itemprop="keywords" content="PopupMenu service,AddItem">
<h2 id="hd_id201589199698158" dir="auto">AddItem</h2>
<p id="par_id93158919963364" class="paragraph" dir="auto">Inserts a menu entry in the popup menu. Returns an integer value that identifies the inserted item.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id821621534012185" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.AddItem(menuitem: str, opt name: str, opt icon: str, opt tooltip: str): int</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id821591631203021" class="paragraph" dir="auto"><span class="emph">menuitem:</span> Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character.</p>
<p id="par_id821591631203026" class="paragraph" dir="auto"><span class="emph">name:</span> String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used.</p>
<p id="par_id11636721652886" class="paragraph" dir="auto"><span class="emph">icon:</span> Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used.</p>
<p id="par_id11636721653118" class="paragraph" dir="auto"><span class="emph">tooltip:</span> Text to be displayed as tooltip.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
myPopup.AddItem("Item A", Tooltip := "A descriptive message")
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
my_popup.AddItem("Item A", tooltip = "A descriptive message")
</code></pre></div>
<a name="AddRadioButton"></a>
<a name="bm_id92158919969447"></a>
<meta itemprop="keywords" content="PopupMenu service,AddRadioButton">
<h2 id="hd_id201589199693022" dir="auto">AddRadioButton</h2>
<p id="par_id93158919969399" class="paragraph" dir="auto">Inserts a radio button entry in the popup menu. Returns an integer value that identifies the inserted item.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id821621534013775" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.AddRadioButton(menuitem: str, opt name: str, opt status: bool = False, opt icon: str, opt tooltip: str): int</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id821591631203501" class="paragraph" dir="auto"><span class="emph">menuitem:</span> Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character.</p>
<p id="par_id821591631228716" class="paragraph" dir="auto"><span class="emph">name:</span> String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used.</p>
<p id="par_id821591631203643" class="paragraph" dir="auto"><span class="emph">status:</span> Defines whether the item is selected when the menu is created (Default = <span class="literal">False</span>).</p>
<p id="par_id11636721653228" class="paragraph" dir="auto"><span class="emph">icon:</span> Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used.</p>
<p id="par_id11636721653114" class="paragraph" dir="auto"><span class="emph">tooltip:</span> Text to be displayed as tooltip.</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
myPopup.AddRadioButton("Option A", Name := "A", Status := True)
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
my_popup.AddRadioButton("Option A", name="A", status=True)
</code></pre></div>
<a name="Execute"></a>
<a name="bm_id92158919962887"></a>
<meta itemprop="keywords" content="PopupMenu service,Execute">
<h2 id="hd_id201589199693201" dir="auto">Execute</h2>
<p id="par_id93158919963279" class="paragraph" dir="auto">Displays the popup menu and waits for a user action. Returns the item clicked by the user.</p>
<p id="par_id101636726249788" class="paragraph" dir="auto">If the user clicks outside the popup menu or presses the <span class="keycode">Esc</span> key, then no item is selected. In such cases, the returned value depends on the <span class="literal">returnid</span> parameter. If <span class="literal">returnid = True</span> and no item is selected, then the value 0 (zero) is returned. Otherwise an empty string "" is returned.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<p id="par_id821621534014414" class="paragraph" dir="auto">
<span class="input" data-tooltip="Click on text to copy to clipboard">svc.Execute(opt returnid: bool = True): any</span>
</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id821591631202088" class="paragraph" dir="auto"><span class="emph">returnid:</span> If <span class="literal">True</span> the selected item ID is returned. If <span class="literal">False</span> the method returns the item's name (Default = <span class="literal">True</span>).</p>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<p id="par_id51636726671698" class="paragraph" dir="auto">In the examples below, a popup menu is created and the item's name is returned because the <span class="literal">returnid</span> argument is set to <span class="literal">False</span>.</p>
<div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
myPopup.AddItem("Item A", Name := "A")
myPopup.AddItem("Item B", Name := "B")
Dim vResponse as Variant
vResponse = myPopup.Execute(False)
</code></pre></div>
<div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
my_popup.AddItem("Item A", name="A")
my_popup.AddItem("Item B", name="B")
response = my_popup.Execute(False)
</code></pre></div>
<div class="embedded">
<a name="SF_InternalUse"></a>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id851506659675843" dir="auto">All <span class="literal">ScriptForge</span> Basic routines or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Basic macros or Python scripts.</p></div>
</div>
<br>
</div>
<a name="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a name="related"></a><span class="emph">Related Topics</span>
</p>
<div class="relatedbody" itemprop="mentions">
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_dialog.html"><span class="literal">SFDialogs</span>.<span class="literal">Dialog</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_dialogcontrol.html"><span class="literal">SFDialogs</span>.<span class="literal">DialogControl</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_menu.html"><span class="literal">SFWidgets</span>.<span class="literal">Menu</span> service</a></p></div>
</div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03/sf_popupmenu.xhp" target="_blank">/text/sbasic/shared/03/sf_popupmenu.xhp</a></p>
<p dir="auto">Title is: SFWidgets.PopupMenu service</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>