Jump to content

WHY IS THE sound_pressed FUNCTION ONLY WORKS FOR BUTTONS BUT NOT INPUT FIELDS?


rossenburg
 Share

Recommended Posts

Hello guys, so i wanted to add a functionality to my mod , where a sound will be played when a user send a message in the chat field.

I noticed when i used the " sound_pressed" function one the send button it worked

<object name="chatSubmit" size="100%-72 100%-26 100%-4 100%-4" sound_pressed="audio/interface/ui/Ugggsentmessage.ogg"  type="button" style="StoneButton">
		<translatableAttribute id="caption">Send</translatableAttribute>
	</object>

when i click on the send button, the sound it triggered as expected but i want to ask how about playing the sound when user press the "ENTER" or "RETURN" button?

 

i tried adding a function called onEnter in style.xml, didn't work too

Quote
<style name="ChatPanel"
		buffer_zone="5"
		font="sans-13"
		scrollbar="true"
		scrollbar_style="ModernScrollBar"
		scroll_bottom="true"
		textcolor="white"
		text_align="left"
		onEnter="Path/to/sound/file"
		
	/>

 

i attached a screen record:cheers:

  • Thanks 1
Link to comment
Share on other sites

32 minutes ago, rossenburg said:

@Stan`, how do I achieve this then? When user press Enter the sound should be triggered too, is there any event handler that covers that. Any suggestions or best practice?

Look at ChatInput.js and use registerChatSubmitHandler() I suppose. Example in Chat.js, or use the submitchat function in Chat.js

To play a sound

Engine.PlayUISound("audio/interface/ui/chat_alert.ogg", false);

Note to self, one should use soundgroups and not raw sound files.

 

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, Stan&#x60; said:

Look at ChatInput.js and use registerChatSubmitHandler() I suppose. Example in Chat.js, or use the submitchat function in Chat.js

To play a sound

Engine.PlayUISound("audio/interface/ui/chat_alert.ogg", false);

Note to self, one should use soundgroups and not raw sound files.

 

Worked like magic @Stan`, TY!:cheers:

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...