MacOs enhanced support #619

Closed
opened 2026-01-29 16:44:14 +00:00 by claunia · 1 comment
Owner

Originally created by @danatcofo on GitHub (Jan 16, 2021).

There are at least 2 different MacOs targeted features that are missing which are kind of important to a fully functioning app.

  • Dock.SetMenu() which is currently in a TODO state
  • App.Activate listener to listen for the app.on('activate') event that indicates a dock click. the activate event also is fired off for other events but for the purposes of Electron.NET, the dock click is the primary missing feature. Without this its impossible to know when the dock icon has been clicked and no windows are open.

I'm planning to implement these myself and create a pr for them, but wanted to open up this feature as a handle to gather any other major macOS interactions that are missing.

Originally created by @danatcofo on GitHub (Jan 16, 2021). There are at least 2 different MacOs targeted features that are missing which are kind of important to a fully functioning app. * Dock.SetMenu() which is currently in a TODO state * App.Activate listener to listen for the `app.on('activate')` event that indicates a dock click. the activate event also is fired off for other events but for the purposes of Electron.NET, the dock click is the primary missing feature. Without this its impossible to know when the dock icon has been clicked and no windows are open. I'm planning to implement these myself and create a pr for them, but wanted to open up this feature as a handle to gather any other major macOS interactions that are missing.
claunia added the Feature label 2026-01-29 16:44:14 +00:00
Author
Owner

@danatcofo commented on GitHub (Jan 18, 2021):

@GregorBiswanger I've got this working locally, I'll have a PR in to support this today or tomorrow at some point as soon as I get all my T's dotted and I's crossed.

Some things of interest here I'm doing to put support in for this I'll make note of.

Dock.setMenu() is a straight forward port of what you do elsewhere and is tested in mac

Support for activate event I'm accomplishing by adding a generic On() and Once() method to the App and Tray modules. I combed through the Electron docs looking for places where events are exposed and those two places seem to be the only places where support isn't already in place for the available events in every case.

for example:

Registering the activate event and consuming it

Electron.App.On("activate", () => {
  // the dock was clicked or activated on macOs
});

// or 

Electron.App.On("activate", obj => {   
   // true there are active windows, false there are not
   var hasWindows = (bool)obj;   
});

The app.ts and tray.ts are implemented to return the second argument of the args list as the first argument is an event object and the second argument is a data object if it exists. This falls in line with the pattern that you have put together elsewhere of having a single object being the argument.

This is not intended to cover all scenarios we might have but it certainly opens up the project to all consumers to target things that are not covered more easily.

@danatcofo commented on GitHub (Jan 18, 2021): @GregorBiswanger I've got this working locally, I'll have a PR in to support this today or tomorrow at some point as soon as I get all my T's dotted and I's crossed. Some things of interest here I'm doing to put support in for this I'll make note of. Dock.setMenu() is a straight forward port of what you do elsewhere and is tested in mac Support for `activate` event I'm accomplishing by adding a generic `On()` and `Once()` method to the App and Tray modules. I combed through the Electron docs looking for places where events are exposed and those two places seem to be the only places where support isn't already in place for the available events in every case. for example: ## Registering the `activate` event and consuming it ```csharp Electron.App.On("activate", () => { // the dock was clicked or activated on macOs }); // or Electron.App.On("activate", obj => { // true there are active windows, false there are not var hasWindows = (bool)obj; }); ``` The app.ts and tray.ts are implemented to return the second argument of the args list as the first argument is an event object and the second argument is a data object if it exists. This falls in line with the pattern that you have put together elsewhere of having a single object being the argument. This is not intended to cover all scenarios we might have but it certainly opens up the project to all consumers to target things that are not covered more easily.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#619