From 9bef4e16b5c2ae38f2b3f7cd2829346735c77be6 Mon Sep 17 00:00:00 2001 From: Justin Lawrence Date: Fri, 15 Nov 2024 07:52:35 -0600 Subject: [PATCH 1/5] doc - menubar enhancement --- resources/views/docs/1/the-basics/menu-bar.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/resources/views/docs/1/the-basics/menu-bar.md b/resources/views/docs/1/the-basics/menu-bar.md index 8f70b546..90bb9a50 100644 --- a/resources/views/docs/1/the-basics/menu-bar.md +++ b/resources/views/docs/1/the-basics/menu-bar.md @@ -99,6 +99,13 @@ To remove the label, you may pass an empty string to the `label()` method. MenuBar::label(''); ``` +### Tooltip + +Add a tooltip to the menu bar icon: +```php +MenuBar::tooltip('Click to open'); +``` + ## Configuring the Menu Bar ### Menu Bar URL @@ -162,6 +169,17 @@ MenuBar::create() ->icon(storage_path('app/menuBarIconTemplate.png')); ``` +### Vibrancy and Background Color + +For macOS, use the `HasVibrancy` trait to apply window vibrancy effects: +```php +MenuBar::create()->vibrancy('light'); +``` + +To create a solid background color instead: +```php +MenuBar::create()->backgroundColor('#ffffff'); +``` ### Menu Bar Window Sizes ![Menu Bar Window Sizes](/img/docs/menubar-window-size.png) @@ -176,6 +194,22 @@ MenuBar::create() ->height(600); ``` +### Resizable Window + +Allow or prevent resizing of the menu bar window: +```php +MenuBar::resizable(false); +``` + +### Positioning + +Set the position of the menu bar window using the `HasPositioner` trait: +```php +MenuBar::create() + ->x(100) + ->y(200); +``` + ### Menu Bar on Top 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,13 @@ window events to the `nativephp` broadcast channel. To learn more about NativePHP's broadcasting capabilities, please refer to the [Broadcasting](/docs/digging-deeper/broadcasting) section. +### Listening for Custom Events + +Attach a custom event handler to the menu bar: +```php +MenuBar::create()->event('custom-event-name'); +``` + ### `MenuBarShown` 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 +277,10 @@ the menu bar gets hidden by using the `MenuBar::hide()` method. ### `MenuBarContextMenuOpened` 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. + +### Context Menu Only + +Show only the context menu without opening a window when the menu bar icon is clicked: +```php +MenuBar::onlyShowContextMenu(); +``` From a27abe4a78ef1b667034ef399f3f0a39084cfeb2 Mon Sep 17 00:00:00 2001 From: Justin Lawrence <43936909+JustinLawrenceMS@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:30:00 -0600 Subject: [PATCH 2/5] Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp --- resources/views/docs/1/the-basics/menu-bar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/docs/1/the-basics/menu-bar.md b/resources/views/docs/1/the-basics/menu-bar.md index 90bb9a50..85c3222b 100644 --- a/resources/views/docs/1/the-basics/menu-bar.md +++ b/resources/views/docs/1/the-basics/menu-bar.md @@ -171,7 +171,7 @@ MenuBar::create() ### Vibrancy and Background Color -For macOS, use the `HasVibrancy` trait to apply window vibrancy effects: +For macOS, you may use the `vibrancy` method to apply window vibrancy effects: ```php MenuBar::create()->vibrancy('light'); ``` From 2acdcd74993f4b10c063388b25d358c1cce674b5 Mon Sep 17 00:00:00 2001 From: Justin Lawrence <43936909+JustinLawrenceMS@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:30:14 -0600 Subject: [PATCH 3/5] Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp --- resources/views/docs/1/the-basics/menu-bar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/docs/1/the-basics/menu-bar.md b/resources/views/docs/1/the-basics/menu-bar.md index 85c3222b..6422fcd6 100644 --- a/resources/views/docs/1/the-basics/menu-bar.md +++ b/resources/views/docs/1/the-basics/menu-bar.md @@ -203,7 +203,7 @@ MenuBar::resizable(false); ### Positioning -Set the position of the menu bar window using the `HasPositioner` trait: +You may manually set the position of the menu bar window: ```php MenuBar::create() ->x(100) From b63243cf4f2098604b1ae3db44b3a1ba5c26c60a Mon Sep 17 00:00:00 2001 From: Justin Lawrence <43936909+JustinLawrenceMS@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:30:32 -0600 Subject: [PATCH 4/5] Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp --- resources/views/docs/1/the-basics/menu-bar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/docs/1/the-basics/menu-bar.md b/resources/views/docs/1/the-basics/menu-bar.md index 6422fcd6..e91503f2 100644 --- a/resources/views/docs/1/the-basics/menu-bar.md +++ b/resources/views/docs/1/the-basics/menu-bar.md @@ -259,7 +259,7 @@ To learn more about NativePHP's broadcasting capabilities, please refer to the [ ### Listening for Custom Events -Attach a custom event handler to the menu bar: +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): ```php MenuBar::create()->event('custom-event-name'); ``` From dd57a7ed09b62f294cb605878ebe40c5939a24d6 Mon Sep 17 00:00:00 2001 From: Justin Lawrence <43936909+JustinLawrenceMS@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:30:54 -0600 Subject: [PATCH 5/5] Update resources/views/docs/1/the-basics/menu-bar.md Co-authored-by: Simon Hamp --- resources/views/docs/1/the-basics/menu-bar.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/views/docs/1/the-basics/menu-bar.md b/resources/views/docs/1/the-basics/menu-bar.md index e91503f2..22f6e350 100644 --- a/resources/views/docs/1/the-basics/menu-bar.md +++ b/resources/views/docs/1/the-basics/menu-bar.md @@ -261,7 +261,17 @@ To learn more about NativePHP's broadcasting capabilities, please refer to the [ 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): ```php -MenuBar::create()->event('custom-event-name'); +MenuBar::create()->event(MenuBarClicked::class); + +class MenuBarClicked +{ + public function __construct(public array $combo, public array $bounds, public array $position) + { + // $combo - details of any combo keys pressed when the click occurred + // $bounds - the current absolute bounds of the menu bar icon at the time of the event + // $position - the absolute cursor position at the time of the event + } +} ``` ### `MenuBarShown`