Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/20/26 15:57
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
ZorroGPT
by TipmyPip. 04/08/26 17:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 3,544 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
juergenwue, VladMak, Geir, ondrej, mredit
19208 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Call function after moving slider? #217318
07/22/08 16:34
07/22/08 16:34
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Is there a way to call a function after the user has moved the position of a hslider or vslider.

I'm building my audio settings menu and i've used some hsliders to represent the "sound effects" volume. I want to be able to play a sound when the slider position has changed so the user can preview the volume.

I have looked in the manual at PANEL* events but they seem to work on the whole panel rather than just its elements.

Can EVENT_CLICK be used to do this?

Thanks

Re: Call function after moving slider? [Re: DJBMASTER] #217333
07/22/08 18:24
07/22/08 18:24
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
Hello,

the only way I can think of at the moment is the following:
Check in a loop if the slider value has been altered and if so, play the sound.

Something like this:
Code:
void sound_settings_menu_loop()
{
	/* store current slider value to become aware of changes */
	var old_slider_value = slider_value;
	
	while(in_sound_settings_menu)
	{
		if ((mouse_left == FALSE) && (old_slider_value != slider_value))
		/* slider has been dragged */
		{
			snd_play(...);
			old_slider_value = slider_value;
		}
		
		wait(1);
	}
}

Probably not the best solution, but it should work.

Re: Call function after moving slider? [Re: Fenriswolf] #217339
07/22/08 18:46
07/22/08 18:46
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
I had thought of this method before i posted but i wondered if there was something built in. I'll see how it works out and reply.

Thanks

Re: Call function after moving slider? [Re: DJBMASTER] #217411
07/22/08 23:44
07/22/08 23:44
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Thanks Feriswolf, it worked better than i thought it would have.

I'd still prefer it if the hslider and vslider objects had an argument like on_changed which accepts a function. It's just easier overall.

I've asked in the future forum...


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1