After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 334726 - enable focus release by arrow key presses (Up, Down)
enable focus release by arrow key presses (Up, Down)
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.6.x
Other All
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-03-16 06:58 UTC by gang
Modified: 2011-02-04 16:11 UTC
See Also:
GNOME target: ---
GNOME version: 2.7/2.8



Description gang 2006-03-16 06:58:53 UTC
We don't need to press Ctrl+Tab to shift the focus out of TextView, but this
only happens when the cursor is on the first or last line.

The implementation:
diff -c gtk/gtktextview.c gtk-keynav/gtktextview.c
*** gtk/gtktextview.c	2006-03-16 14:51:26.502541776 +0800
--- gtk-keynav/gtktextview.c	2006-03-16 14:51:16.697603510 +0800
***************
*** 3855,3860 ****
--- 3855,3874 ----
  
    insert = gtk_text_buffer_get_insert (get_buffer (text_view));
    gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, insert);
+   //For key navigation by Gang WANG
+   int lineCount = gtk_text_buffer_get_line_count (get_buffer (text_view));
+   int curLine = gtk_text_iter_get_line (&iter);
+   if (curLine == 0 && (event->keyval == GDK_Up || event->keyval == GDK_KP_Up))
+   {
+     gtk_text_view_move_focus (text_view,GTK_DIR_TAB_BACKWARD);
+     return TRUE;
+   }
+   else if (curLine == (lineCount - 1) && (event->keyval == GDK_Down ||
event->keyval == GDK_KP_Down))
+   {
+     gtk_text_view_move_focus (text_view,GTK_DIR_TAB_FORWARD);
+     return TRUE;
+   }
+   //End of key navigation
    can_insert = gtk_text_iter_can_insert (&iter, text_view->editable);
    if (can_insert &&
        gtk_im_context_filter_keypress (text_view->im_context, event))

Other information:
For embedded devices such as phones which don't have Tab keys, this will be
quite useful.
Comment 1 Michael Natterer 2006-05-10 10:35:51 UTC
See bug #322640 for a more general solution.
Comment 2 Michael Natterer 2006-11-16 13:05:14 UTC
Fixed in CVS. Bug reporters, please check your use cases and file
new bugs against the new features if anything doesn't work. It doesn't
make sense to keep 6 bugs open.

2006-11-16  Michael Natterer  <mitch@imendio.com>

	Add new infrastructure for notifications of failed keyboard
	navigation and navigation with restricted set of keys.

	The patch handles configurable beeping, navigating the GUI with
	cursor keys only (as in phone environments), and configurable
	wrap-around. Fixes bugs #322640, #70986, #318827, #334726, #334742
	and #309291.

	* gtk/gtksettings.c: added properties gtk-keynav-cursor-only,
	gtk-keynav-wrap-around and gtk-error-bell.

	* gtk/gtkwidget.[ch]: added new signal "keynav-failed" and public
	API to emit it. Added New function gtk_widget_error_bell() which
	looks at the gtk-error-bell setting and calls gdk_window_beep()
	accordingly.

	* gtk/gtk.symbols: add the new widget symbols.

	* gtk/gtkcellrendereraccel.c
	* gtk/gtkimcontextsimple.c
	* gtk/gtkmenu.c
	* gtk/gtknotebook.c: use gtk_widget_error_bell() or look at the
	gtk-error-bell setting instead of calling gdk_display_beep()
	unconditionally.

	* gtk/gtkcombobox.c
	* gtk/gtkentry.c
	* gtk/gtkiconview.c
	* gtk/gtklabel.c
	* gtk/gtkmenushell.c
	* gtk/gtkspinbutton.c
	* gtk/gtktextview.c
	* gtk/gtktreeview.c: call gtk_widget_error_bell() on failed keynav.

	* gtk/gtkentry.c
	* gtk/gtklabel.c
	* gtk/gtkrange.c
	* gtk/gtktextview.c: consult gtk_widget_keynav_failed() on failed
	cursor navigation and leave the widget if it returns FALSE.

	* gtk/gtkmenushell.c
	* gtk/gtknotebook.c: only wrap around if gtk-keynav-wrap-around
	is TRUE.

	* gtk/gtkradiobutton.c: ask gtk_widget_keynav_failed() to decide
	whether to to wrap-around, and don't select active items on cursor
	navigation if gtk-keynav-cursor-only is TRUE. Should look at
	gtk-keynav-wrap-around too, will look into that.
Comment 3 gang 2007-04-12 09:51:08 UTC
If hbox should respect wrap_around, it will be a little bit more convenient for users to navigate in a group of icons packed in a hbox. And the same case for vbox.
Should this be implemented in GtkContainer or respectively in hbox and vbox?

(In reply to comment #2)
> Fixed in CVS. Bug reporters, please check your use cases and file
> new bugs against the new features if anything doesn't work. It doesn't
> make sense to keep 6 bugs open.
> 
> 2006-11-16  Michael Natterer  <mitch@imendio.com>
> 
>         Add new infrastructure for notifications of failed keyboard
>         navigation and navigation with restricted set of keys.
> 
>         The patch handles configurable beeping, navigating the GUI with
>         cursor keys only (as in phone environments), and configurable
>         wrap-around. Fixes bugs #322640, #70986, #318827, #334726, #334742
>         and #309291.
> 
>         * gtk/gtksettings.c: added properties gtk-keynav-cursor-only,
>         gtk-keynav-wrap-around and gtk-error-bell.
> 
>         * gtk/gtkwidget.[ch]: added new signal "keynav-failed" and public
>         API to emit it. Added New function gtk_widget_error_bell() which
>         looks at the gtk-error-bell setting and calls gdk_window_beep()
>         accordingly.
> 
>         * gtk/gtk.symbols: add the new widget symbols.
> 
>         * gtk/gtkcellrendereraccel.c
>         * gtk/gtkimcontextsimple.c
>         * gtk/gtkmenu.c
>         * gtk/gtknotebook.c: use gtk_widget_error_bell() or look at the
>         gtk-error-bell setting instead of calling gdk_display_beep()
>         unconditionally.
> 
>         * gtk/gtkcombobox.c
>         * gtk/gtkentry.c
>         * gtk/gtkiconview.c
>         * gtk/gtklabel.c
>         * gtk/gtkmenushell.c
>         * gtk/gtkspinbutton.c
>         * gtk/gtktextview.c
>         * gtk/gtktreeview.c: call gtk_widget_error_bell() on failed keynav.
> 
>         * gtk/gtkentry.c
>         * gtk/gtklabel.c
>         * gtk/gtkrange.c
>         * gtk/gtktextview.c: consult gtk_widget_keynav_failed() on failed
>         cursor navigation and leave the widget if it returns FALSE.
> 
>         * gtk/gtkmenushell.c
>         * gtk/gtknotebook.c: only wrap around if gtk-keynav-wrap-around
>         is TRUE.
> 
>         * gtk/gtkradiobutton.c: ask gtk_widget_keynav_failed() to decide
>         whether to to wrap-around, and don't select active items on cursor
>         navigation if gtk-keynav-cursor-only is TRUE. Should look at
>         gtk-keynav-wrap-around too, will look into that.
>