<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../style.css">
<title>
Gambas Documentation - TrayIcon
 (gb.qt)</title>
</head>
<body>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../../help%3Fen"><img class="flag" alt="Home" border="0" src="../../../img/lang/en.png" align="center"></a>&nbsp;&nbsp;
<a href="../gb.qt%3Fen">Up</a>&nbsp;&nbsp;
<a href="toolbutton/_new%3Fen">Previous</a>&nbsp;&nbsp;
<a href="trayicon/_dblclick%3Fen">Next</a>&nbsp;&nbsp;
</td></tr></table>
<div class="notab">
<h1>
TrayIcon
 (gb.qt)</h1>
This class implements a tray icon.
<p>
<div class="black"><font color="white" size="-2"><b>Symbols</b></font></div>
<div class="border">
This class is <a href="trayicon/_new%3Fen">creatable</a>.<br>
<hr><table class="none" cellspacing="0" cellpadding="0">
<tr>
<td align=left><b>Properties</b></td><td width="32">&nbsp;</td>
<td align=left><b>Methods</b></td><td width="32">&nbsp;</td>
<td align=left><b>Events</b></td><td width="32">&nbsp;</td>
</tr>
<tr valign=top>
<td>
<a href="trayicon/h%3Fen">H</a>&nbsp;&nbsp; <a href="trayicon/height%3Fen">Height</a>&nbsp;&nbsp; <a href="trayicon/icon%3Fen">Icon</a>&nbsp;&nbsp; <a href="trayicon/picture%3Fen">Picture</a>&nbsp;&nbsp; <a href="trayicon/screenx%3Fen">ScreenX</a>&nbsp;&nbsp; <a href="trayicon/screeny%3Fen">ScreenY</a>&nbsp;&nbsp; <a href="trayicon/tag%3Fen">Tag</a>&nbsp;&nbsp; <a href="trayicon/text%3Fen">Text</a>&nbsp;&nbsp; <a href="trayicon/tooltip%3Fen">Tooltip</a>&nbsp;&nbsp; <a href="trayicon/visible%3Fen">Visible</a>&nbsp;&nbsp; <a href="trayicon/w%3Fen">W</a>&nbsp;&nbsp; <a href="trayicon/width%3Fen">Width</a>&nbsp;&nbsp; </td><td>&nbsp;</td>
<td>
<a href="trayicon/hide%3Fen">Hide</a>&nbsp;&nbsp; <a href="trayicon/show%3Fen">Show</a>&nbsp;&nbsp; </td><td>&nbsp;</td>
<td>
<a href="trayicon/_dblclick%3Fen">DblClick</a>&nbsp;&nbsp; <a href="trayicon/_enter%3Fen">Enter</a>&nbsp;&nbsp; <a href="trayicon/_gotfocus%3Fen">GotFocus</a>&nbsp;&nbsp; <a href="trayicon/_leave%3Fen">Leave</a>&nbsp;&nbsp; <a href="trayicon/_lostfocus%3Fen">LostFocus</a>&nbsp;&nbsp; <a href="trayicon/_menu%3Fen">Menu</a>&nbsp;&nbsp; <a href="trayicon/_mousedown%3Fen">MouseDown</a>&nbsp;&nbsp; <a href="trayicon/_mousemove%3Fen">MouseMove</a>&nbsp;&nbsp; <a href="trayicon/_mouseup%3Fen">MouseUp</a>&nbsp;&nbsp; <a href="trayicon/_mousewheel%3Fen">MouseWheel</a>&nbsp;&nbsp; </td><td>&nbsp;</td>
</tr>
</table>
</div><p>

<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../../img/warning.png" align="center"></td><td valign="top">
The KDE panel easily crashes if you create and remove a tray icon several times, for example during
a debugging session. Apparently, this is a bug in the KDE panel.
</td></tr></table></div>
<p>

<div class="example">
A <a href="trayicon%3Fen">TrayIcon</a> typically responds to either the <a href="trayicon/_dblclick%3Fen">DblClick</a> event to initiate a preset action (for instance to restore a minimized <a href="form%3Fen">Form</a>) or the <a href="trayicon/_menu%3Fen">Menu</a> event to
produce a popup <a href="menu%3Fen">Menu</a>.  My observations are that creating a popup on the fly is troublesome
and that it is best to create a <i>&quot;stub&quot;</i> <a href="menu%3Fen">Menu</a> in your <a href="form%3Fen">Form</a> and set that menu's <a href="control/enabled%3Fen">Enabled</a> property to <a href="../../lang/false%3Fen">FALSE</a> and its <a href="control/visible%3Fen">Visible</a> property to <a href="../../lang/false%3Fen">FALSE</a>.  The you can add and remove items with ease to match the current state of the
application in the available popup menu options.
<p>
You can also use the <a href="control/tooltip%3Fen">ToolTip</a> property of the <a href="trayicon%3Fen">TrayIcon</a> to display application status
when such behavior is appropriate to your particular project.
<p>
You create a hidden invisible menu in your main form called <b>TrayMenu</b> whose identifier
is also <b>TrayMenu</b>.  You give your TrayIcon control the identifier <b>MyTrayIcon</b>.  You want
to create a context menu for your <a href="trayicon%3Fen">TrayIcon</a>.  For this example <b>TrayMenu</b> and <b>MyTrayIcon</b>
need to be in the same <a href="form%3Fen">Form</a>.
<p>
In the form containing <b>MyTrayIcon</b> and <b>TrayMenu</b>:
<pre class="example">Public Sub MyTrayIcon_Menu()

    TrayMenu.Popup()

End
</pre><p><p>
There may be stability issues with the use of this control at present.
<p>
In my attempt to use this control I've had the KDE panel segfault (crash) on several
occasions after a number of edit/run cycles of a <a href="../../def/gambas%3Fen">Gambas</a> project using a TrayIcon in the
startup form.
<p>
--<b>Brian Jack 2006.01.29 02:28 PST</b>
<p>
Can you be more precise about what is troublesome in creating a popup menu?
<p>
--<b>Benoit Minisini 2006.01.29 22:59 CET</b>
<p>
If you use the <a href="form%3Fen">Form</a> as a parent and create the popup <a href="menu%3Fen">Menu</a> you need to add a bunch of bookkeeping to make sure the menu is only created once otherwise a menubar with several copies of the popup menu results.  Since I do not believe there is a way to delete objects at this time it is just as well to make a persistent <a href="menu%3Fen">Menu</a> within the <a href="form%3Fen">Form</a> in the <u>IDE Menu Editor</u> then call it up from the TrayIcon's <a href="menu%3Fen">Menu</a> event.
<p>
--<b>Brian Jack 2006.02.02 09:49 PST</b>
</div>

</div>
<hr>
</body>
</html>

