added focus in and out callbacks

This commit is contained in:
Darren Ranalli 2002-08-23 21:23:04 +00:00
parent 44b4f2c068
commit 5931561dfe
1 changed files with 16 additions and 0 deletions

View File

@ -39,6 +39,11 @@ class DirectEntry(DirectFrame):
# Command to be called on hitting Enter
('command', None, None),
('extraArgs', [], None),
# commands to be called when focus is gained or lost
('focusInCommand', None, None),
('focusInExtraArgs',[], None),
('focusOutCommand',None, None),
('focusOutExtraArgs',[], None),
# Sounds to be used for button events
('rolloverSound', getDefaultRolloverSound(), self.setRolloverSound),
('clickSound', getDefaultClickSound(), self.setClickSound),
@ -78,6 +83,9 @@ class DirectEntry(DirectFrame):
# Bind command function
self.bind(ACCEPT, self.commandFunc)
self.accept(self.guiItem.getFocusInEvent(), self.focusInCommandFunc)
self.accept(self.guiItem.getFocusOutEvent(), self.focusOutCommandFunc)
# Call option initialization functions
self.initialiseoptions(DirectEntry)
@ -122,6 +130,14 @@ class DirectEntry(DirectFrame):
if self['command']:
# Pass any extra args to command
apply(self['command'], [self.get()] + self['extraArgs'])
def focusInCommandFunc(self):
if self['focusInCommand']:
apply(self['focusInCommand'], self['focusInExtraArgs'])
def focusOutCommandFunc(self):
if self['focusOutCommand']:
apply(self['focusOutCommand'], self['focusOutExtraArgs'])
def set(self, text):
self.guiItem.setText(text)