Send message on enter

Docc - November 13, 2009 - 14:13
Project:Chat Room
Version:6.x-2.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:justinrandell
Status:closed
Description

The module is coming along really well. Nice work.
Question though. How about binding a jquery listener to the textbox. So if the user press enter the message is send (and alt+enter for a new line)

#1

Docc - November 13, 2009 - 14:32

guess it could look something like this (shift + enter is new line)

$('#edit-chatroom-message-entry-box').keyup(function(e) {
  var messageText = $('#edit-chatroom-message-entry-box').val();
  if (messageText && e.keyCode == 13 && !e.shiftKey) {
      Drupal.chatroom.postMessage(messageText);
      $('#edit-chatroom-message-entry-box').val('').focus();
   };
});

#2

justinrandell - November 14, 2009 - 11:25
Assigned to:Anonymous» justinrandell

yes, i think this is fine. i use pidgin, and i notice that you can use both shift+enter or ctrl+enter to enter a new line, so perhaps we should support both as well?

#3

Docc - November 14, 2009 - 15:24

Yeah why not.

It might be a idea to look at the following jquery plugin http://code.google.com/p/js-hotkeys/
It allows easy binding of key combinations. Because i can image there will be some more shortcuts in the future? (maybe even variable) and its only 4.4kb in size.

#4

justinrandell - November 14, 2009 - 15:31

looks interesting, but will likely be after the first stable release.

i also want to bring back sound effects via a jquery plugin, so i'll be looking at how to handle adding jquery plugins as (possibly optional) dependencies at that point.

#5

justinrandell - November 14, 2009 - 15:32

oh yeah, got any opinions about #629400: make private chats controls easier to use ?

#6

justinrandell - November 15, 2009 - 01:30
Status:active» fixed

committed, thanks! please reopen if you see any issues.

#7

System Message - November 29, 2009 - 01:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.