how to avoid bell on key_down in listctrl

hi all.

when I press down a key in a ListCtrl, the computer bells. Because I've
binded EVT_LIST_KEY_DOWN, some keys trigger special functions while
others leave alone. I don't want the bell puzzle our users.

How can I avoid the bell or replace it with another sound (supplied by
myself)?

I've created a validator as follows and associate it with the ListCtrl,
but it doesn't work.

---- codes ----

class MyValidator(wx.PyValidator):
    def __init__(self, pyVar=None):
        wx.PyValidator.__init__(self)
        self.SetBellOnError(True)

    def Clone(self):
        return MyValidator()

self.l = wx.ListCtrl(self, -1, validator=MyValidator(),
         style=wx.LC_REPORT|wx.TAB_TRAVERSAL|wx.WANTS_CHARS|wx.CLIP_CHILDREN)

hi all.

when I press down a key in a ListCtrl, the computer bells. Because I've
binded EVT_LIST_KEY_DOWN, some keys trigger special functions while
others leave alone. I don't want the bell puzzle our users.

How can I avoid the bell or replace it with another sound (supplied by
myself)?

I've created a validator as follows and associate it with the ListCtrl,
but it doesn't work.

---- codes ----

class MyValidator(wx.PyValidator):
    def __init__(self, pyVar=None):
        wx.PyValidator.__init__(self)
        self.SetBellOnError(True)

          ^^^^^^^^^^^^^^^^^^^^^^^^^
          get rid of this line

···

zyf_sz <zyf_sz@tom.com> wrote:

    def Clone(self):
        return MyValidator()

self.l = wx.ListCtrl(self, -1, validator=MyValidator(),
         style=wx.LC_REPORT|wx.TAB_TRAVERSAL|wx.WANTS_CHARS|wx.CLIP_CHILDREN)

zyf_sz wrote:

hi all.

when I press down a key in a ListCtrl, the computer bells. Because I've
binded EVT_LIST_KEY_DOWN, some keys trigger special functions while
others leave alone. I don't want the bell puzzle our users.

How can I avoid the bell or replace it with another sound (supplied by
myself)?

IIRC, the bell happens when the native control sees the key-up event but not the key-down, or something like that. So you may want to experiment with things like also catching the key-up and ignoring those keys you handled in the key-down, or perhaps always calling evt.Skip even if you do handle the keys, etc.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I'm not sure if I have catch your words. I've did that in anothe way.

In my original idea, those special key are single pressed without 'alt',
'ctrl' or some likes. But this conflicts with ListCtrl's default key
event which will select the item whose word starts with the key I
pressed.

So, I have rebinded those special keys with wx.KeyEvent.m_controlDown
test. That works fine without annoying bell. Just leave the default
keyevent alone.

Zhang