Playsound when button pressed not released?

BlitzMax Forums/MaxGUI Module/Playsound when button pressed not released?

CopperCircle(Posted 2007) [#1]
Hi, I want to play a sound as soon as a button is pressed, but when using Event/Select the sound always plays when the button is release with the mouse. Any ideas...?


DavidDC(Posted 2007) [#2]
Perhaps use an active panel or a canvas instead and play on the mouse click itself, after you've checked the mouse is indeed inside the correct rect.

- David


Brucey(Posted 2007) [#3]
when using Event/Select the sound always plays when the button is release with the mouse.

Ah yes, that's because MaxGUI Buttons don't have a "mouse down" event on Win32/Mac. Tis a shame really, as those platforms are just as capable as GTK in supporting more events.

You may have to resort to what David says above, unfortunately.


CopperCircle(Posted 2007) [#4]
hmm, a bit of a pain. Brucey does your new GUI module allow this?


Brucey(Posted 2007) [#5]
It does now ;-)

Gadgets/Widgets by default only support a small set of events - like a button tends only to be interested in button-clicks.
However, it is possible to tell a widget that it is interested in all kinds of events, and then all you need to do is sub-class it, and Connect the new events to the instance of the widget.

I've just added support for this with wxButton, so an example I knocked together would look like this :

We extend wxButton, and connect a Left-mouse-button Down event to it. Now, when you press the button, it first fires off the event.
"event.Skip()" forwards the mouse event onwards to the button proper - otherwise the button would never know you clicked!

It has potential... but still has a way to go until it's finished... getting there :-)


CopperCircle(Posted 2007) [#6]
Thats, great thanks allot.