Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
gb
gb.args
gb.cairo
gb.chart
gb.clipper
gb.complex
gb.compress
gb.crypt
gb.data
gb.db
gb.db.form
gb.db.mysql
gb.db.odbc
gb.db.postgresql
gb.db.sqlite2
gb.db.sqlite3
gb.dbus
gb.dbus.trayicon
gb.debug
gb.desktop
gb.desktop.gnome.keyring
gb.desktop.x11
gb.eval
gb.eval.highlight
gb.form
gb.form.dialog
gb.form.editor
gb.form.htmlview
gb.form.mdi
gb.form.print
gb.form.stock
gb.form.terminal
gb.gmp
gb.gsl
gb.gtk
gb.gtk.opengl
gb.gtk3
gb.gtk3.opengl
gb.gtk3.webview
gb.gui
gb.gui.opengl
gb.gui.qt
gb.gui.qt.opengl
gb.gui.qt.webkit
gb.gui.trayicon
gb.gui.webview
gb.hash
gb.highlight
gb.image
gb.image.effect
gb.image.imlib
gb.image.io
gb.inotify
gb.jit
gb.libxml
gb.logging
gb.map
gb.markdown
gb.media
gb.media.form
gb.memcached
gb.mime
gb.mysql
gb.ncurses
gb.net
gb.net.curl
gb.net.pop3
gb.net.smtp
gb.openal
gb.opengl
gb.opengl.glsl
gb.opengl.glu
gb.opengl.sge
gb.openssl
gb.option
gb.pcre
gb.pdf
gb.poppler
gb.qt4
.combobox.item
.container.children
.Menu.Children
.TabStripContainer
.TabStripContainer.Children
.TextArea.Selection
.TextBox.Selection
.Window.Controls
.Window.Menus
_ColumnView_Columns
_ComboBox_Item
_ComboBox_Selection
_Draw_Clip
_Draw_Style
_GridView_Cell
_GridView_Column
_GridView_Columns
_GridView_Data
_GridView_Row
_GridView_Rows
_IconView_Item
_ListBox_Item
_split
_TreeView
_TreeView_Item
Action
Align
Animation
Application
Arrange
Border
Button
CheckBox
Clipboard
Color
ColumnView
ComboBox
Container
ContainerChildren
Control
Cursor
Desktop
Dialog
Direction
Drag
Draw
DrawingArea
embedder
Fill
Font
Fonts
Form
Frame
GridView
HBox
HPanel
HSplit
IconView
Image
Key
Label
Line
ListBox
ListView
Menu
Message
Mouse
MovieBox
Paint
PaintBrush
PaintExtents
PaintMatrix
Panel
Picture
PictureBox
Point
Pointer
PointF
Printer
ProgressBar
RadioButton
Rect
RectF
Screen
Screens
Scroll
ScrollArea
ScrollBar
ScrollView
Select
Separator
Slider
SpinBox
Splitter
Spring
Style
SvgImage
TabStrip
TextArea
TextBox
TextLabel
ToggleButton
ToolButton
trayicon
:dblclick ?
:enter ?
:gotfocus ?
:leave ?
:lostfocus ?
:menu ?
:mousedown ?
:mousemove ?
:mouseup ?
:mousewheel ?
_new ?
delete ?
h ?
height ?
hide ?
icon ?
picture ?
popupmenu ?
screenx ?
screeny ?
show ?
tag ?
text ?
tooltip ?
visible ?
w ?
width ?
trayicons
TreeView
UserContainer
UserControl
VBox
VPanel
VSplit
Watcher
Window
Windows
gb.qt4.ext
gb.qt4.opengl
gb.qt4.webkit
gb.qt4.webview
gb.qt5
gb.qt5.ext
gb.qt5.opengl
gb.qt5.webkit
gb.qt5.webview
gb.report
gb.report2
gb.scanner
gb.sdl
gb.sdl.sound
gb.sdl2
gb.sdl2.audio
gb.settings
gb.signal
gb.term
gb.test
gb.util
gb.util.web
gb.v4l
gb.vb
gb.web
gb.web.feed
gb.web.form
gb.web.gui
gb.xml
gb.xml.html
gb.xml.rpc
gb.xml.xslt
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

trayicon (gb.qt4)

This class implements a tray icon.

trayicon: This class does not exist.

A trayicon typically responds to either the :dblclick ? event to initiate a preset action (for instance to restore a minimized Form) or the :menu ? event to produce a popup Menu. My observations are that creating a popup on the fly is troublesome and that it is best to create a "stub" Menu in your Form and set that menu's Enabled property to FALSE and its Visible property to FALSE. Then you can add and remove items with ease to match the current state of the application in the available popup menu options.

You can also use the Tooltip property of the trayicon to display application status when such behavior is appropriate to your particular project.

You create a hidden invisible menu in your main form called TrayMenu whose identifier is also TrayMenu. You give your TrayIcon control the identifier MyTrayIcon. You want to create a context menu for your trayicon. For this example TrayMenu and MyTrayIcon need to be in the same Form.

In the form containing MyTrayIcon and TrayMenu:
Public Sub MyTrayIcon_Menu()

    TrayMenu.Popup()

End

There may be stability issues with the use of this control at present.

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 Gambas project using a TrayIcon in the startup form.

--Brian Jack 2006.01.29 02:28 PST

Can you be more precise about what is troublesome in creating a popup menu?

--Benoit Minisini 2006.01.29 22:59 CET

If you use the Form as a parent and create the popup Menu 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 Menu within the Form in the IDE Menu Editor then call it up from the TrayIcon's Menu event.

--Brian Jack 2006.02.02 09:49 PST