TrayItem

From Xojo Documentation

Revision as of 18:56, 19 November 2009 by WikiSysop (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Description

Used to add items to the System Tray. Windows and Linux only.


Super Class

Object

Events

Name Parameters Description
Action Cause as Integer The user has clicked on the TrayItem.

The parameter Cause indicates the type of click. To determine the kind of click, use the following class constants: DoubleClick LeftMouseButton RightMouseButton


Properties

Name Type Description
Handle
Introduced 2009r4
Ptr Returns the window handle that the TrayItem belongs to on Windows and the GtkStatusIcon widget on Linux. On Windows, the first TrayItem has a ID of 1000 and subsequent adds will increment this ID.
HelpTag String Help associated with the TrayItem.
Icon Picture The icon displayed as the TrayItem.


Class Constants

The following class constants can be used in the Action event to determine the way the user clicked on the TrayItem.

Class Constants Description
DoubleClick The user double-clicked.
LeftMouseButton The user held down the Left mouse button and clicked.
RightMouseButton The user held down the Right mouse button and clicked.


Examples

Add an instance of the TrayItem class, myAppTrayItem, to your project and then instantiate it in the Open event of the App object, i.e.,

Dim myTrayItem as myAppTrayItem
myTrayItem = New MyAppTrayItem
Me.AddTrayItem( myTrayItem )

The following code in the Action event of the TrayItem handles mouse clicks and double-clicks.

If cause = TrayItem.LeftMouseButton then
MsgBox "Left Mouse Button Down"
elseif cause = TrayItem.RightMouseButton then
Dim mnu as new MenuItem
    
 mnu.Append( new MenuItem( "&About" ) )
 mnu.Append( new MenuItem( MenuItem.TextSeparator ) )
 mnu.Append( new MenuItem( "E&xit" ) )
Dim results as MenuItem
 results = mnu.PopUp
    
 if results <> nil then
select case results.Text
   case "E&xit"
  case "&About"
MsgBox "The REALbasic TrayItem demo."
        
  end select
 end if
    
elseif cause = TrayItem.DoubleClick then
MsgBox "Double Click"
end if

When the application quits, you call the RemoveTrayItem method of the Application class. This goes in the Close event handler of the App object.

Me.RemoveTrayItem(myTrayItem)


See Also

Application class.