How can I attach a context menu to a TreeWidget derived widget?

Hi all,
I have a widget MyTestWidget that is derived from TreeWidget from theia core.
How can I attach a context menu to MyTestWidget ? Any sample would be very helpful.
Thanks in advance.

I referred to the Debug Watch widget implementation in theia:
This seems like a good example.

However, in my widget (that is derived from TreeWidget), during initialization of ContainerModule, i’m setting the context menu as shown below:

    const child = createTreeContainer(parent);
    /*other init code*/
    /*more initialization*/
export const TEST_VIEW_PROPS = <TreeProps>{
    contextMenuPath: TestViewMenus.TEST_VIEW_CONTEXT_MENU,
    multiSelect: true,
    search: true,
    globalSelection: true

export class TestViewMenus {
    static TEST_VIEW_CONTEXT_MENU: MenuPath = ['TEST-view-context-menu'];
    static TEST_VIEW = [...TestViewMenus.TEST_VIEW_CONTEXT_MENU, 'TEST-view'];

and in frontend-contribution class:

    registerCommands(registry: CommandRegistry): void {

        registry.registerCommand(TestViewCommands.OPEN, {
            isEnabled: () => true,
            execute: () =>

        registry.registerCommand(TestViewCommands.DELETE, {
            isEnabled: () => true,
            execute: () => this.delete()

    registerMenus(menus: MenuModelRegistry): void {

        menus.registerMenuAction(TestViewMenus.TEST_VIEW, {
            order: '0'
        menus.registerMenuAction(TestViewMenus.TEST_VIEW, {
            order: '1'

But, when I right click the an item in the tree view, no context menu appears… Pls help.

Snippets which you shared looks good. It is hard to say without running.