24 System Tray
This section covers system tray icon support.
24.1 Creating a Tray
procedure
icon : (or/c surface? #f) = #f tooltip : (or/c string? #f) = #f cust : custodian? = (current-custodian)
icon is an optional surface to use as the tray icon. tooltip is optional tooltip text.
(define tray (make-tray)) (set-tray-tooltip! tray "My Application")
procedure
(tray-destroy! tr) → void?
tr : tray?
Note: Trays are automatically destroyed when their custodian shuts down.
procedure
(set-tray-icon! tr icon) → void?
tr : tray? icon : (or/c surface? #f)
procedure
(set-tray-tooltip! tr tooltip) → void?
tr : tray? tooltip : (or/c string? #f)
24.2 Menus
procedure
(make-tray-menu tr) → tray-menu?
tr : tray?
procedure
(get-tray-menu tr) → (or/c tray-menu? #f)
tr : tray?
procedure
(tray-menu? v) → boolean?
v : any/c
procedure
(tray-menu-ptr menu) → cpointer?
menu : tray-menu?
24.3 Menu Entries
procedure
(insert-tray-entry! menu label [ #:position pos #:type type #:checked? checked? #:disabled? disabled?]) → tray-entry? menu : tray-menu? label : string? pos : exact-integer? = -1 type : (or/c 'button 'checkbox 'submenu) = 'button checked? : boolean? = #f disabled? : boolean? = #f
pos is the position (-1 = end).
'button —
A clickable item 'checkbox —
A toggleable item 'submenu —
An item that opens a submenu
(define menu (make-tray-menu tray)) (define quit-entry (insert-tray-entry! menu "Quit")) (set-tray-entry-callback! quit-entry (lambda (entry) (exit)))
procedure
(remove-tray-entry! entry) → void?
entry : tray-entry?
procedure
(tray-entry? v) → boolean?
v : any/c
procedure
(tray-entry-ptr entry) → cpointer?
entry : tray-entry?
procedure
(tray-entries menu) → (listof tray-entry?)
menu : tray-menu?
24.4 Entry Properties
procedure
(tray-entry-label entry) → (or/c string? #f)
entry : tray-entry?
procedure
(set-tray-entry-label! entry label) → void?
entry : tray-entry? label : string?
procedure
(tray-entry-checked? entry) → boolean?
entry : tray-entry?
procedure
(set-tray-entry-checked! entry checked?) → void?
entry : tray-entry? checked? : boolean?
procedure
(tray-entry-enabled? entry) → boolean?
entry : tray-entry?
procedure
(set-tray-entry-enabled! entry enabled?) → void?
entry : tray-entry? enabled? : boolean?
24.5 Entry Callbacks
procedure
(set-tray-entry-callback! entry proc [ #:userdata userdata]) → void? entry : tray-entry? proc : (or/c procedure? #f) userdata : any/c = #f
1 arg: (entry)
2 args: (entry userdata)
Pass #f to remove the callback.
(set-tray-entry-callback! entry (lambda (e) (printf "Entry clicked: ~a~n" (tray-entry-label e))))
procedure
(click-tray-entry! entry) → void?
entry : tray-entry?
24.6 Submenus
procedure
(make-tray-submenu entry) → tray-menu?
entry : tray-entry?
procedure
(tray-submenu entry) → (or/c tray-menu? #f)
entry : tray-entry?
procedure
(tray-menu-parent-entry menu) → (or/c tray-entry? #f)
menu : tray-menu?
procedure
(tray-menu-parent-tray menu) → (or/c cpointer? #f)
menu : tray-menu?
procedure
(tray-entry-parent entry) → (or/c tray-menu? #f)
entry : tray-entry?
24.7 Updates
procedure
(update-trays!) → void?
Call this periodically to ensure tray changes are reflected.