How to enable right-click menu in TraitsUI TreeView when using adaptors?
<p>I have modified the <a href="https://github.com/enthought/traitsui/blob/master/examples/demo/Advanced/Adapted_tree_editor_demo.py" rel="nofollow noreferrer">Adapted_tree_editor_demo.py</a> example code to display some simple model objects using the adaptor approach. However, right-click menu options are all <strong>disabled</strong>. How can I enable them? Implementing <code>can_delete_me()</code> and <code>confirm_delete()</code> does not seem to help.</p>

<p><a href="https://i.stack.imgur.com/rvT1u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rvT1u.png" alt="Disabled menu items."></a></p>

<pre><code>from os \
    import getcwd

from traits.api \
    import HasTraits, Property, Directory, Instance, Str, List, adapts, property_depends_on

from traitsui.api \
    import View, ModelView, VGroup, Item, TreeEditor, ITreeNode, ITreeNodeAdapter

from pkg_resources import resource_filename
traits_icons_path = resource_filename("traitsui", "wx/images")

# Model classes to adapt

class Person(HasTraits):

    name = Str('Bob')

class Department(HasTraits):

    name = Str('Sales')

    people = List(Person)


# FileAdapter Class

class PersonAdapter ( ITreeNodeAdapter ):

    adapts( Person, ITreeNode )

    def allows_children ( self ):
        """ Returns whether this object can have children.
        """
        return False

    def has_children ( self ):
        """ Returns whether the object has children.
        """
        return False

    def get_children ( self ):
        """ Gets the object's children.
        """
        return []

    def get_label ( self ):
        """ Gets the label to display for a specified object.
        """
        return self.adaptee.name

    def get_tooltip ( self ):
        """ Gets the tooltip to display for a specified object.
        """
        if self.adaptee.name == 'Bob':
            return 'This is Bob, he is a man.'
        elif self.adaptee.name == 'Alice':
            return 'This is Alice, she is a woman.'
        return 'An employee of a department.'

    def get_icon_path(self):
        """ Return the path of the icons
        """
        return traits_icons_path

    def get_icon ( self, is_expanded ):
        """ Returns the icon for a specified object.
        """
        if self.adaptee.name == 'Bob':
            return 'file'
        elif self.adaptee.name == 'Alice':
            return 'object'
        else:
            return 'item'

    def can_auto_close ( self ):
        """ Returns whether the object's children should be automatically
            closed.
        """
        return True

    def can_delete_me(self):
        return True

    def confirm_delete(self):
        return True


class DepartmentAdapter ( ITreeNodeAdapter ):

    adapts( Department, ITreeNode )

    def allows_children ( self ):
        """ Returns whether this object can have children.
        """
        return True

    def has_children ( self ):
        """ Returns whether the object has children.
        """
        return len(self.adaptee.people) &gt; 0

    def get_children ( self ):
        """ Gets the object's children.
        """
        return self.adaptee.people

    def get_label ( self ):
        """ Gets the label to display for a specified object.
        """
        return self.adaptee.name

    def get_tooltip ( self ):
        """ Gets the tooltip to display for a specified object.
        """
        return 'The {} department'.format(self.adaptee.name)

    def get_icon ( self, is_expanded ):
        """ Returns the icon for a specified object.
        """
        if is_expanded:
            return '&lt;open&gt;'   
        return '&lt;close&gt;'

    def can_auto_close ( self ):
        """ Returns whether the object's children should be automatically
            closed.
        """
        return True

# Create main view

class DepartmentView(ModelView):

    model = Instance(Department)

    # The traits view to display:
    view = View(
        VGroup(
            Item( 'object.model.name', style='readonly'),
            Item( 'model',
                  editor = TreeEditor( editable = False, auto_open = 1 )
            ),
            show_labels = False
        ),
        width     = 0.33,
        height    = 0.50,
        resizable = True
    )


# Create model object graph

bob = Person(name='Bob')
alice = Person(name='Alice')
dept = Department(name='Sales', people=[bob, alice])

view = DepartmentView(model=dept)

# Run the demo (if invoked form the command line):
if __name__ == '__main__':
    view.configure_traits()
</code></pre>