Author: cazfi
Date: Sun Apr 26 17:50:45 2015
New Revision: 28887

URL: http://svn.gna.org/viewcvs/freeciv?rev=28887&view=rev
Log:
Fixed sdl2-client chat input handling

See bug #23527

Modified:
    branches/S2_6/client/gui-sdl2/chatline.c

Modified: branches/S2_6/client/gui-sdl2/chatline.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/chatline.c?rev=28887&r1=28886&r2=28887&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/chatline.c    (original)
+++ branches/S2_6/client/gui-sdl2/chatline.c    Sun Apr 26 17:50:45 2015
@@ -337,7 +337,9 @@
 **************************************************************************/
 static int inputline_return_callback(struct widget *pWidget)
 {
-  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+  if (Main.event.type == SDL_KEYDOWN
+      && (Main.event.key.keysym.sym == SDLK_RETURN
+          || Main.event.key.keysym.sym == SDLK_KP_ENTER)) {
 
     if (pWidget->string_utf8->text == NULL) {
       return -1;
@@ -501,12 +503,16 @@
 **************************************************************************/
 static int input_edit_conn_callback(struct widget *pWidget)
 {
-  if (Main.event.button.button == SDL_BUTTON_LEFT) { 
+  if (Main.event.type == SDL_KEYDOWN
+      && (Main.event.key.keysym.sym == SDLK_RETURN
+          || Main.event.key.keysym.sym == SDLK_KP_ENTER)) {
     if (pWidget->string_utf8->text != NULL) {
       if (pWidget->string_utf8->text[0] != '\0') {
         send_chat(pWidget->string_utf8->text);
       }
 
+      free(pWidget->string_utf8->text);
+      pWidget->string_utf8->text = fc_malloc(1);
       pWidget->string_utf8->n_alloc = 0;
     }
   }
@@ -768,7 +774,7 @@
 
   /* input field */
 
-  pBuf = create_edit_from_chars(NULL, pWindow->dst, NULL,
+  pBuf = create_edit_from_chars(NULL, pWindow->dst, "",
                                 adj_font(12), pWindow->size.w - adj_size(10) - 
adj_size(10),
                                 (WF_RESTORE_BACKGROUND|WF_EDIT_LOOP));
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to