Can I send a BMessage to a Deskbar replicant?

Is there an easy way to get a BMessage to a replicant in the Deskbar tray?

I’d have hoped that after checking with Deskbar’s HasItem() there’d be a way to send a BMessage to the Deskbar and have it pass it on to the named BView (or using the item’s ID). No such luck, though…

It’s not the most straightforward, but it can be done with the scripting API. I don’t have any C++ code showing it but I can give some examples using hey to target a replicant in the Deskbar. For example, to send a refresh message to my DeskbarWeather replicant:

hey Deskbar let View of Replicant "DeskbarWeatherView" of Shelf of View Status of Window Deskbar do 'FrGw'

My replicant view is named “DeskbarWeatherView” and ‘FrGw’ is the refresh message.

Thanks for that hint!

I’ve found code in the repo that does something in that direction with the ShelfInspector.
I hope someone comes up with an easier way, otherwise I’ll have to try wrapping my tiny brain around what’s described there… :slight_smile:

I don’t think there is another way currently without writing code to use some other method to send data, like a shared clipboard or a message port. There’s an open ticket about locating views in the Deskbar.

I have an app similar to ShelfInspector hiding in my projects folder that I haven’t pushed to github if you need more examples.

Semi-related …some other miscellaneous hey commands for inspecting the shelf and replicants if anyone is curious:

# getsuites command to show what info is available to query/command
hey Deskbar getsuites of Replicant 0 of Shelf of View Status of Window Deskbar
hey Deskbar getsuites of Shelf of View Status of Window Deskbar

# get replicant count
hey Deskbar count Replicant of Shelf of View Status of Window Deskbar

# get archive of replicant by index
hey Deskbar get Replicant 0 of Shelf of View Status of Window Deskbar

# get archive of replicant by name
hey Deskbar get Replicant "ProcessController" of Shelf of View Status of Window Deskbar

Thanks. I don’t know yet when I’ll find the time to dig into it. I may come back to your offer some day…

Look at how the Deskbar replicant communicates with the plug-in for Claws that I’ve created.
It’s done via StartWatching/StopWatching and SendNotices. In this particular use case I send a message to the application and the replicant receives a notice of that specific message.

Thanks, I’ll look into that, too. If nobody quickly implements BMessage forwarding to Deskbar in the next days… :slight_smile:

Sending a message to the Deskbar is not a problem, you can do it. You want to send a message to the replicant’s view that it’s not straightforward.
We probably need an API to easily iterate over the available replicants and get the one we need by name.

Here is how it’s done in the input _server:

I am painfully aware. :slight_smile:
[EDIT: rereading the post you answered, I meant that we’d need to have Deskbar forward the BMessage we send to it to the replicant with a certain ID or name. But just getting the BMessenger of the replicant may be even more straigt forward.]

We already have that API with Deskbar’s HasItem(). Only that returns just the ID (corresponds to the position of the replicant in the tray, I think). We’d need the addition to ask for the BMessenger of the view of that ID (or name, works too).

@korli , yeah that’s similar ‘scripting’ approach as seen in the ShelfInspector.
I’d wish for a fewer-hoops solution, but may have to go that way or the listener way and Start/StopWatching for those notices…