Skip to content

Commit

Permalink
MenuBars continued (#137)
Browse files Browse the repository at this point in the history
* Destroy the existing menu bar

* Standardise events
  • Loading branch information
simonhamp authored Nov 26, 2024
1 parent 5bc2582 commit baae218
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions resources/js/electron-plugin/src/server/api/menuBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ router.post("/create", (req, res) => {
res.sendStatus(200);

if (state.activeMenuBar) {
return;
state.activeMenuBar.tray.destroy();
}

const {
Expand All @@ -83,19 +83,6 @@ router.post("/create", (req, res) => {

tray.setContextMenu(buildMenu(contextMenu));

if (event) {
tray.on('click', (combo, bounds, position) => {
notifyLaravel('events', {
event,
payload: {
combo,
bounds,
position,
},
});
});
}

state.activeMenuBar = menubar({
tray,
tooltip,
Expand Down Expand Up @@ -164,15 +151,41 @@ router.post("/create", (req, res) => {
});
});

state.activeMenuBar.tray.on("right-click", () => {
state.activeMenuBar.tray.on('click', (combo, bounds, position) => {
notifyLaravel('events', {
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarClicked",
payload: {
combo,
bounds,
position,
},
});
});

state.activeMenuBar.tray.on("right-click", (combo, bounds) => {
notifyLaravel("events", {
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarContextMenuOpened"
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarRightClicked",
payload: {
combo,
bounds,
}
});

if (! onlyShowContextMenu) {
state.activeMenuBar.hideWindow();
state.activeMenuBar.tray.popUpContextMenu(buildMenu(contextMenu));
}
});

state.activeMenuBar.tray.on('double-click', (combo, bounds) => {
notifyLaravel('events', {
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarDoubleClicked",
payload: {
combo,
bounds,
},
});
});
});
});

Expand Down

0 comments on commit baae218

Please sign in to comment.