Skip to content

Commit eca229b

Browse files
JustinLawrenceMSJustin Lawrencesimonhamp
authored
doc - menubar enhancement (#59)
* doc - menubar enhancement * Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp <simon.hamp@me.com> * Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp <simon.hamp@me.com> * Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp <simon.hamp@me.com> * Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp <simon.hamp@me.com> --------- Co-authored-by: Justin Lawrence <justinlawrence@mac.mynetworksettings.com> Co-authored-by: Simon Hamp <simon.hamp@me.com>
1 parent e40c38d commit eca229b

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

resources/views/docs/1/the-basics/menu-bar.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ To remove the label, you may pass an empty string to the `label()` method.
9999
MenuBar::label('');
100100
```
101101

102+
### Tooltip
103+
104+
Add a tooltip to the menu bar icon:
105+
```php
106+
MenuBar::tooltip('Click to open');
107+
```
108+
102109
## Configuring the Menu Bar
103110

104111
### Menu Bar URL
@@ -162,6 +169,17 @@ MenuBar::create()
162169
->icon(storage_path('app/menuBarIconTemplate.png'));
163170
```
164171

172+
### Vibrancy and Background Color
173+
174+
For macOS, you may use the `vibrancy` method to apply window vibrancy effects:
175+
```php
176+
MenuBar::create()->vibrancy('light');
177+
```
178+
179+
To create a solid background color instead:
180+
```php
181+
MenuBar::create()->backgroundColor('#ffffff');
182+
```
165183
### Menu Bar Window Sizes
166184

167185
![Menu Bar Window Sizes](/img/docs/menubar-window-size.png)
@@ -176,6 +194,22 @@ MenuBar::create()
176194
->height(600);
177195
```
178196

197+
### Resizable Window
198+
199+
Allow or prevent resizing of the menu bar window:
200+
```php
201+
MenuBar::resizable(false);
202+
```
203+
204+
### Positioning
205+
206+
You may manually set the position of the menu bar window:
207+
```php
208+
MenuBar::create()
209+
->x(100)
210+
->y(200);
211+
```
212+
179213
### Menu Bar on Top
180214

181215
When developing a menu bar application, you may want to make sure that the menu bar window is always open and on top of all other windows.
@@ -223,6 +257,23 @@ window events to the `nativephp` broadcast channel.
223257

224258
To learn more about NativePHP's broadcasting capabilities, please refer to the [Broadcasting](/docs/digging-deeper/broadcasting) section.
225259

260+
### Listening for Custom Events
261+
262+
Attach a custom event that should be fired when the menu bar icon is clicked. This only works when combined with [`onlyShowContextMenu()`](#context-menu-only):
263+
```php
264+
MenuBar::create()->event(MenuBarClicked::class);
265+
266+
class MenuBarClicked
267+
{
268+
public function __construct(public array $combo, public array $bounds, public array $position)
269+
{
270+
// $combo - details of any combo keys pressed when the click occurred
271+
// $bounds - the current absolute bounds of the menu bar icon at the time of the event
272+
// $position - the absolute cursor position at the time of the event
273+
}
274+
}
275+
```
276+
226277
### `MenuBarShown`
227278

228279
The `Native\Laravel\Events\MenuBar\MenuBarShown` event will be dispatched when the user clicks on the menu bar icon and the menu bar window opens, or when
@@ -236,3 +287,10 @@ the menu bar gets hidden by using the `MenuBar::hide()` method.
236287
### `MenuBarContextMenuOpened`
237288

238289
The `Native\Laravel\Events\MenuBar\MenuBarContextMenuOpened` event will be dispatched when the user right-clicks on the menu bar icon and the context menu opens.
290+
291+
### Context Menu Only
292+
293+
Show only the context menu without opening a window when the menu bar icon is clicked:
294+
```php
295+
MenuBar::onlyShowContextMenu();
296+
```

0 commit comments

Comments
 (0)