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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...