SteveEdson/bitbar-php

submenu example does not work

gingerbeardman opened this issue · 5 comments

// Create BitBar formatter
$bb = new BitBar();

// Create the first line
$line = $bb->newLine();

// Set the text and formatting
$mainMenu = $line
    ->setText("Servers")
    ->setColour("yellow");

$mainMenu = $mainMenu->addSubMenu()
    ->newLine()
    ->setText("Server 1")
    ->setUrl('http://server1.com');

$mainMenu = $mainMenu->addSubMenu()
    ->newLine()
    ->setText("Server 2")
    ->setUrl('http://server2.com');

$mainMenu->show();

I see
screen shot 2018-06-19 at 12 58 20

Good question, most of it can be recreated like so:

$bb = new BitBar();

$places = $bb->newLine()
    ->setText("Places");

$placesData = ['London', 'Paris', 'Tokyo'];

foreach($placesData as $place) {
    $places = $places->addSubMenu()
       ->newLine()
       ->setText($place);
}

$places->show();

However, there isn't any support for nested submenus just yet.

This would need to change from the $withinSubMenu approach currently implemented, to something like $depth. I've taken a quick stab at this on the branch feature/nested-submenus, but there's more work required to get this working. (If you run the test example, you'll see that its increasing the depth for every item at the moment).

It'd be a big help if you could open a PR and continue this work, otherwise I'll try to find some more time to look into this later.

Cheers!

I'll try to find some time, cheers for work done so far

@gingerbeardman
Ever get to the bottom of the submenu issue? I'm seeing the same thing.

@JonLaliberte no, and sadly no idea what the current state of affairs is with BitBar - sorry