diff --git a/direct/src/gui/DirectButton.py b/direct/src/gui/DirectButton.py index 0ed5523854..c4d3a819d1 100644 --- a/direct/src/gui/DirectButton.py +++ b/direct/src/gui/DirectButton.py @@ -44,6 +44,7 @@ class DirectButton(DirectFrame): # Sounds to be used for button events ('rolloverSound', DGG.getDefaultRolloverSound(), self.setRolloverSound), ('clickSound', DGG.getDefaultClickSound(), self.setClickSound), + ('releaseSound', DGG.getDefaultReleaseSound(), self.setReleaseSound), # Can only be specified at time of widget contruction # Do the text/graphics appear to move when the button is clicked ('pressEffect', 1, DGG.INITOPT), @@ -108,6 +109,13 @@ class DirectButton(DirectFrame): # Pass any extra args to command self['command'](*self['extraArgs']) + def setRolloverSound(self): + rolloverSound = self['rolloverSound'] + if rolloverSound: + self.guiItem.setSound(DGG.ENTER + self.guiId, rolloverSound) + else: + self.guiItem.clearSound(DGG.ENTER + self.guiId) + def setClickSound(self): clickSound = self['clickSound'] # Clear out sounds @@ -122,9 +130,16 @@ class DirectButton(DirectFrame): if DGG.RMB in self['commandButtons']: self.guiItem.setSound(DGG.B3PRESS + self.guiId, clickSound) - def setRolloverSound(self): - rolloverSound = self['rolloverSound'] - if rolloverSound: - self.guiItem.setSound(DGG.ENTER + self.guiId, rolloverSound) - else: - self.guiItem.clearSound(DGG.ENTER + self.guiId) + def setReleaseSound(self): + releaseSound = self['releaseSound'] + # Clear out sounds + self.guiItem.clearSound(DGG.B1RELEASE + self.guiId) + self.guiItem.clearSound(DGG.B2RELEASE + self.guiId) + self.guiItem.clearSound(DGG.B3RELEASE + self.guiId) + if releaseSound: + if DGG.LMB in self['commandButtons']: + self.guiItem.setSound(DGG.B1RELEASE + self.guiId, releaseSound) + if DGG.MMB in self['commandButtons']: + self.guiItem.setSound(DGG.B2RELEASE + self.guiId, releaseSound) + if DGG.RMB in self['commandButtons']: + self.guiItem.setSound(DGG.B3RELEASE + self.guiId, releaseSound) diff --git a/direct/src/gui/DirectCheckBox.py b/direct/src/gui/DirectCheckBox.py index fc0ce5f5ca..d1cff642a8 100755 --- a/direct/src/gui/DirectCheckBox.py +++ b/direct/src/gui/DirectCheckBox.py @@ -28,6 +28,7 @@ class DirectCheckBox(DirectButton): # Sounds to be used for button events ('rolloverSound', DGG.getDefaultRolloverSound(), self.setRolloverSound), ('clickSound', DGG.getDefaultClickSound(), self.setClickSound), + ('releaseSound', DGG.getDefaultReleaseSound(), self.setReleaseSound), # Can only be specified at time of widget contruction # Do the text/graphics appear to move when the button is clicked ('pressEffect', 1, DGG.INITOPT), diff --git a/direct/src/gui/DirectGuiGlobals.py b/direct/src/gui/DirectGuiGlobals.py index d41199af0e..1048f8d724 100644 --- a/direct/src/gui/DirectGuiGlobals.py +++ b/direct/src/gui/DirectGuiGlobals.py @@ -17,8 +17,9 @@ from panda3d.core import ( defaultFont = None defaultFontFunc = TextNode.getDefaultFont -defaultClickSound = None defaultRolloverSound = None +defaultClickSound = None +defaultReleaseSound = None defaultDialogGeom = None defaultDialogRelief = PGFrameStyle.TBevelOut drawOrder = 100 @@ -129,6 +130,13 @@ def setDefaultClickSound(newSound): global defaultClickSound defaultClickSound = newSound +def getDefaultReleaseSound(): + return defaultReleaseSound + +def setDefaultReleaseSound(newSound): + global defaultReleaseSound + defaultReleaseSound = newSound + def getDefaultFont(): global defaultFont if defaultFont is None: