Replies: 4 comments 2 replies
-
Yeh, I agree, this would be really nice. I'm currently refactoring the Menu API as it's a little clunky, so I'm going to add this into it |
Beta Was this translation helpful? Give feedback.
-
You can now use the |
Beta Was this translation helpful? Give feedback.
-
Managed to make it work using Window::url(), thanks, Simon! Full example in case someone else needs this as well: Menu::new()
->appMenu()
->fileMenu()
->editMenu()
->viewMenu()
->windowMenu()
->submenu('Tools', Menu::new()
->event(\App\Events\Menu\RestoreBackupMenuItemClicked::class, 'Restore Backup')
)
->register();
<?php
namespace App\Events\Menu;
class RestoreBackupMenuItemClicked
{
}
<?php
namespace App\Listeners\Menu;
use App\Events\Menu\RestoreBackupMenuItemClicked;
use Window;
class RedirectToRestoreBackupPage
{
public function handle(RestoreBackupMenuItemClicked $event): void
{
Window::get('main')->url(route('plain.restore-backup'));
}
} |
Beta Was this translation helpful? Give feedback.
-
Here's the PR that will allow us to do this directly from a menu item. It'll look something like this: Menu::goToUrl(url('/path/to/page'));
// or
Menu::goToRoute('route.name') |
Beta Was this translation helpful? Give feedback.
-
When using the application menu, you should be able to programmatically change the route for a given window.
Something like this would be really clean.
The first parameter is the route you want to go to, and the second the window that you want to do it in.
Maybe even default to
main
when a route is given.That way you don't need to register an event and listen for it.
However if you want to do that, then it would be nice if you could go something like
Same as when you do
Beta Was this translation helpful? Give feedback.
All reactions