diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py index 20184b657a..2843be7694 100644 --- a/direct/src/gui/DirectEntry.py +++ b/direct/src/gui/DirectEntry.py @@ -53,6 +53,9 @@ class DirectEntry(DirectFrame): # Command to be called on hitting Enter ('command', None, None), ('extraArgs', [], None), + # Command to be called when enter is hit but we fail to submit + ('failedCommand', None, None), + ('failedExtraArgs',[], None), # commands to be called when focus is gained or lost ('focusInCommand', None, None), ('focusInExtraArgs', [], None), @@ -94,6 +97,7 @@ class DirectEntry(DirectFrame): # Bind command function self.bind(DGG.ACCEPT, self.commandFunc) + self.bind(DGG.ACCEPTFAILED, self.failedCommandFunc) self.accept(self.guiItem.getFocusInEvent(), self.focusInCommandFunc) self.accept(self.guiItem.getFocusOutEvent(), self.focusOutCommandFunc) @@ -149,6 +153,11 @@ class DirectEntry(DirectFrame): # Pass any extra args to command apply(self['command'], [self.get()] + self['extraArgs']) + def failedCommandFunc(self, event): + if self['failedCommand']: + # Pass any extra args + apply(self['failedCommand'], [self.get()] + self['failedExtraArgs']) + def focusInCommandFunc(self): if self['focusInCommand']: apply(self['focusInCommand'], self['focusInExtraArgs']) diff --git a/direct/src/gui/DirectGuiGlobals.py b/direct/src/gui/DirectGuiGlobals.py index e6681da5ce..c26220a6b5 100644 --- a/direct/src/gui/DirectGuiGlobals.py +++ b/direct/src/gui/DirectGuiGlobals.py @@ -70,6 +70,7 @@ B3RELEASE = PGButton.getReleasePrefix() + MouseButton.three().getName() + '-' # For DirectEntry widgets OVERFLOW = PGEntry.getOverflowPrefix() ACCEPT = PGEntry.getAcceptPrefix() + KeyboardButton.enter().getName() + '-' +ACCEPTFAILED = PGEntry.getAcceptFailedPrefix() + KeyboardButton.enter().getName() + '-' TYPE = PGEntry.getTypePrefix() ERASE = PGEntry.getErasePrefix() # For DirectSlider and DirectScrollBar widgets