Using TrayItem on Linux

Hi,
I’m trying for the first time to create an app that runs from the tray in
Linux.

I started with the code from the Language Ref:

I created the class: Tray As AppTrayItem

in the App.Open event handler:
Tray = New AppTrayItem
If Not Self.AddTrayItem(Tray) Then
// There was an error adding the TrayItem
msgbox “It didn’t work”
End If

I also put in the code suggested for clicks and closing the tray

The app compiles and runs, but not in the tray and i don’t see the error
message I put in app open.

Is anyone familiar with this?

Thanks,
Don

Did you miss the step creating a property on the App Class?

I’m guessing from the code you used the the docs… [link]

  • Create a class in the project called AppTrayItem and change it’s super to TrayItem
  • Create a property in the app class called Tray and change it’s type to be this new class AppTrayItem

Then your code in the open event should(!) work… Don’t forget to close the TrayItem in the App classes close event.

it does not work for me too. (Elementary OS 32bit)

my Code

#if TargetLinux then Tray = New AppTrayItem Tray.Icon = date16 Tray.HelpTag = "Test" If Not Self.AddTrayItem(Tray) Then // There was an error adding the TrayItem msgbox "It didn't work" End If #endif

Ran a quick test on my Mint 32Bit VM and it works there.

Only step I missed is setting an icon for the TrayItem.

Hi Patrick,
Thanks for your reply. Yes I do have the App property. I tried it today with a new project that has nothing in it except a window and the TrayItem code. It still launches and appears in the task bar at the bottom, but it does not go into the tray and I do not get the message box telling me it failed.
I’m using Xojo 2013r3, although TrayItems have apparently been around since the Real Studio days. I’m also trying it on a 3 year old Debian Squeeze install with Gnome 2.
Also, launching the test app from the console does not produce any error messages.

I’m going to try it on a newer Linux system.

Thanks again for your help
Don

I switched to Linux Lite 3.0 (based on Ubuntu 16.04.1) 32bit

there it works.

Hi Axel,
I’ve tried it on Mint 17.3, which is also a Ubuntu derivative and it still insists on running in the task bar.
I’m using the Mate desktop. Which one are you using?

I used the code, copied and pasted, from:
http://documentation.xojo.com/index.php/TrayItem
If you used different code, would youmind sending me what you used so I can try it here?

Thanks,

Don

I am using xfce4, code is the same

here an app where I use it
https://www.dropbox.com/s/ptertigllaz62q2/temperature.zip?dl=1

Thanks Axel,
It works. I had missed the part about putting in an icon.

Unfortunately, I seem to have asked the wrong question. What I want to do is build something that works like the “Screenlets” set of apps. These run in the tray, but leave a window open on the screen and do not appear in the taskbar.

The main thing I want is “not in the task bar”. The tray part isn’t actually necessary.

Sorry I didn’t ask this right. And thanks for your help!
Don

In Windows, Modal windows don’t have taskbar icons. Could it be the same with some luck ?

in Mono I use

this.SkipTaskbarHint = true;

I don’t know how to do it in Xojo.

I found a way to do this “not in the task bar”

LinuxDeclares