switch ($modx->event->name) {
case 'OnResourceToolbarLoad':
$modx->log(modX::LOG_LEVEL_ERROR, 'Triggered on OnResourceToolbarLoad');
$action = (isset ($modx->actionMap) && isset($modx->actionMap['resource/create']) ) ? $modx->actionMap['resource/create'] : 'resource/create';
$scriptProperties['items'][] = array(
'icon' => 'assets/components/moregallery/mgr/img/picture.png',
'tooltip' => 'add new gallery',
'handler' => 'new Function("this.redirect(\"index.php?a='.$action.'&class_key=mgResource\");");'
);
$items[] = array(
'icon' => 'assets/components/moregallery/mgr/img/picture.png',
'tooltip' => 'add new gallery',
'handler' => 'new Function("this.redirect(\"index.php?a='.$action.'&class_key=mgResource\");");'
);
break;$this->modx->invokeEvent('OnResourceToolbarLoad',array(
'items' => &$items,
));
return $this->modx->error->success('',$items);This question has been answered by markh. See the first response.

<?php
/**
* @var modX $modx
* @var array $scriptProperties
*
* @event OnManagerPageBeforeRender
*/
$modx->controller->addHtml('<script>Ext.onReady(function() {
var tree = Ext.getCmp("modx-resource-tree");
var tb = tree.getTopToolbar();
tb.add({
icon: "404.png",
tooltip: "Tip tip ?",
handler: function() {
console.log("clicked")
}
});
tb.doLayout();
});</script>');
return '';

switch ($modx->event->name) {
case 'OnManagerPageBeforeRender':
/**
* @var modManagerController $controller
*/
if (!$modx->getOption('moregallery.add_icon_to_toolbar', null, true)) {
return;
}
$controller->addHtml(<<<HTML
<script>
MODx.on('ready', function() {
var tree = Ext.getCmp('modx-resource-tree'),
tb = tree.getTopToolbar();
setTimeout(function() {
tb.insertButton(4, {
icon: '/assets/components/moregallery/mgr/img/picture.png',
tooltip: 'Add Gallery',
handler: function() {
var action = (MODx.action && MODx.action['resource/create']) ? MODx.action['resource/create'] : 'resource/create';
MODx.loadPage(action, 'class_key=mgResource');
}
});
tb.doLayout();
}, 150);
});
</script>
HTML
);
}