Accepting keys doesn't work


unfortunately I’m unable to figure out how to “accept” a simple button press. I mean it works good, but not for german umlauts etc, for example it should print acceptedBut: ö after I press the Ö key several times.

Thanks for your help!


Below is my example(Windows xp):

# -*- coding: cp1252 -*-
import sys

from direct.showbase.DirectObject import DirectObject
from panda3d import direct 
from panda3d.core import ButtonThrower
from panda3d.core import TextNode
from panda3d.core import CardMaker

from direct.directbase import DirectStart

class Keys(DirectObject):
    def __init__(self):      
        self.accept('stroked', self.buttons,['stroked'])

        self.mes.setText('press alt+f4 to exit')       
    def acceptedBut(self, but):
        print ("acceptedBut: " + but)
    def buttons(self,tag,but):

        out = but
        out = out.encode("utf8")
        base.accept(but, self.acceptedBut, [but])
        if but=='escape':

The method DirectObject is not a callback - it registers some function as a callback. Calling base.accept from within the callback method “buttons” doesn’t make any sense to me.

Try this:

    def buttons(self, key):
        out = key.encode('utf-8')
        print("accepted:", (key, out))
        if out == u'\x1b': # escape

What do you mean with method DirectObject? I thought it’s a class.

It’s supposed to make base accept any key that I pressed so that after someone hit a key, the next time acceptedBut would also be called for that key.

I tried to bind the Ö key that way but it didn’t work.

Sorry, I wanted to type DirectObject.accept.

You already register a handler for all keystrokes, the method “buttons”. So why registering a second handler for particular keys? Or do you just want to find out how to register a handler for only a single key?

Ah ok. Yes I’m trying to register a handler for a single key but something like self.accept(‘ö’, self.buttons,[‘stroked’]) etc didn’t work.

Thank you for your help!

As a side note the events set with base.buttonThrowers[0].node().setButtonDownEvent(‘bdown’) and base.buttonThrowers[0].node().setButtonUpEvent(‘bup’) are also not fired for noneascii keys, e.g. ÖÖÄß don’t trigger any of the above events. How can I get events for any of these keys?

It seems strange because I can enter any of the chars into a DirectEntry but I would like to use CEGUI so I need a way to accept events for these keys.

No one has any tips? :frowning:
I filed a bug report because it looks like one to me.