DirectEntry and Accept

In my program I have a global Input class that tracks keypresses and run different functions based on what’s happening in the game.

I’ve recently added a directentry command and I’m realizing that an individual keypress is being processed by both the input class and the directentry object which I don’t want to happen. For example the ‘r’ key controls some functions in the game and if a person presses ‘r’ during writing in the directentry box, the ‘r’ function is called.

Is there a way to insure than when the directentry object is created that it has exclusive control over the keypresses and then relinquish control back to the input class?

This may not be possible- if not I’ll just have to find some work-around.

It’s definitely possible.
Basically, you can use suppressKeys=1 for your DE’s init setting, to block keypresses from triggering any event.
But unfortunately, DE suppresses keys not only when it’s in focus, but also when the mouse rolls over it (while it’s not in focus).

A clean way to work around this is creating a wrapper class of DE, which does these :

  1. focusInCommand : run a function to alter the default button thrower’s current prefix
  2. focusOutCommand : run a function to restore button thrower’s previous prefix

Button thrower prefix is added as events’ prefix, e.g. :
prefix : ‘’ (nothing), event : ‘myEvent’
prefix : ‘DE in focus-’, event : ‘DE in focus-myEvent’

The default button thrower object is :
base.buttonThrowers[0].node()

I use it heavily in here (I use 3 wrapped DGUI classes) :
discourse.panda3d.org/viewtopic.php?t=2642