views:

20

answers:

0

Hey. I am trying to disable the Context Menu in a TextCtrl widget under wxpython (prevent the context menu from coming up when right clicked). If I create my on Menu and bind it to the right mouse click it will always show my menu but if I dont create menu under right mouse click event it automatically creates a standard conext menu, even if I dont call event.Skip() (see sample code). Is this a bug? Any ideas for a way around this standard context menu?

    self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown)

def OnMouseRightDown(self, event):
    pt = event.GetPosition()
    self.RightClickContext(event, pt, True)

def RightClickContext(self, event, pt, enable):

    menu = wx.Menu()
    undo = menu.Append(ID_UNDO, 'Undo')
    menu.AppendSeparator()
    cut = menu.Append(ID_CUT, 'Cut')
    copy = menu.Append( ID_COPY, 'Copy' )        
    paste = menu.Append( ID_PASTE, 'Paste' )
    menu.AppendSeparator()
    delete = menu.Append( ID_DELETE, 'Delete' )
    selectall = menu.Append( ID_SELECTALL, 'Select All' )
    undo.Enable(False)
    cut.Enable(False)
    copy.Enable(False)
    if enable:
        paste.Enable(True)
    else:
        paste.Enable(False)
    delete.Enable(False)
    selectall.Enable(False)

    wx.EVT_MENU(menu, ID_PASTE,  self.MenuPaste)

    self.PopupMenu(menu, pt)
    menu.Destroy()