Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#12898) Better unit keynav for laptops
Home

[Freeciv-Dev] (PR#12898) Better unit keynav for laptops

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12898) Better unit keynav for laptops
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Mon, 17 Oct 2005 13:02:03 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12898 >

> [vasc - Tue Apr 26 14:01:57 2005]:
> 
> Lots of people have complained about it, because they do not have a
> numeric keypad. They should be using goto, but for that goto needs to
> allow unknown tile destinations. That should be a separate ticket.
> 
> The regular arrow keys should also be allowed for unit movement, however
> suboptimal they may be for not having diagonal directions. People are
> just too used to them.
> 
> Proposed user-side design:
> #1 Selecting the map widget allows using the arrow keys.
> #2 Mouse over the map widget selects it automatically.
> 
> Kudos to Mike Kaufman for suggesting #2. We should implement both.

Here is a small patch which implements this.

Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c       (revision 11148)
+++ client/gui-gtk-2.0/gui_main.c       (working copy)
@@ -405,18 +405,41 @@
 
        case GDK_Home:
          key_center_capital();
-         break;
+         return TRUE;
 
        case GDK_Return:
        case GDK_KP_Enter:
          key_end_turn();
-         break;
+         return TRUE;
   
        default:
          break;
       }
     }
 
+    if (GTK_WIDGET_HAS_FOCUS(map_canvas)) {
+      switch (ev->keyval) {
+       case GDK_Left:
+         key_unit_move(DIR8_WEST);
+         return TRUE;
+
+       case GDK_Right:
+         key_unit_move(DIR8_EAST);
+         return TRUE;
+
+       case GDK_Up:
+         key_unit_move(DIR8_NORTH);
+         return TRUE;
+
+       case GDK_Down:
+         key_unit_move(DIR8_SOUTH);
+         return TRUE;
+
+       default:
+         break;
+      }
+    }
+
     switch (ev->keyval) {
       case GDK_KP_Up:
       case GDK_8:
Index: client/gui-gtk-2.0/mapctrl.c
===================================================================
--- client/gui-gtk-2.0/mapctrl.c        (revision 11148)
+++ client/gui-gtk-2.0/mapctrl.c        (working copy)
@@ -367,6 +367,10 @@
 **************************************************************************/
 gboolean move_mapcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
 {
+  if (!GTK_WIDGET_HAS_FOCUS(map_canvas)) {
+    gtk_widget_grab_focus(map_canvas);
+  }
+
   update_line(ev->x, ev->y);
   update_rect_at_mouse_pos();
   if (keyboardless_goto_button_down && hover_state == HOVER_NONE) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12898) Better unit keynav for laptops, Vasco Alexandre da Silva Costa <=