Index: /CKEditor/branches/features/toolbargroup2/_source/plugins/toolbar/plugin.js
===================================================================
--- /CKEditor/branches/features/toolbargroup2/_source/plugins/toolbar/plugin.js	(revision 6718)
+++ /CKEditor/branches/features/toolbargroup2/_source/plugins/toolbar/plugin.js	(revision 6719)
@@ -59,8 +59,13 @@
 		init : function( editor )
 		{
+			var endFlag;
+
 			var itemKeystroke = function( item, keystroke )
 			{
 				var next, toolbar;
-				var rtl = editor.lang.dir == 'rtl';
+				var rtl = editor.lang.dir == 'rtl',
+					toolbarGroupCycling = editor.config.toolbarGroupCycling;
+
+				toolbarGroupCycling = toolbarGroupCycling === undefined || toolbarGroupCycling;
 
 				switch ( keystroke )
@@ -77,11 +82,14 @@
 
 							// Look for the first item that accepts focus.
-							item = toolbar.items.length && toolbar.items[ 0 ];
-							while ( item && !item.focus )
+							if ( toolbar.items.length )
 							{
-								item = item.next;
-
-								if ( !item )
-									toolbar = 0;
+								item = toolbar.items[ endFlag ? ( toolbar.items.length - 1 ) : 0 ];
+								while ( item && !item.focus )
+								{
+									item = endFlag ? item.previous : item.next;
+
+									if ( !item )
+										toolbar = 0;
+								}
 							}
 						}
@@ -94,23 +102,23 @@
 					case rtl ? 37 : 39 :		// RIGHT-ARROW
 					case 40 :					// DOWN-ARROW
+						next = item;
 						do
 						{
 							// Look for the next item in the toolbar.
-							next = item.next;
+							next = next.next;
 
 							// If it's the last item, cycle to the first one.
-							if ( !next )
+							if ( !next && toolbarGroupCycling )
 								next = item.toolbar.items[ 0 ];
-
-							item = next;
 						}
-						while ( item && !item.focus )
+						while ( next && !next.focus )
 
 						// If available, just focus it, otherwise focus the
 						// first one.
-						if ( item )
-							item.focus();
+						if ( next )
+							next.focus();
 						else
-							editor.toolbox.focus();
+							// Send a TAB.
+							itemKeystroke( item, 9 );
 
 						return false;
@@ -118,25 +126,26 @@
 					case rtl ? 39 : 37 :		// LEFT-ARROW
 					case 38 :					// UP-ARROW
+						next = item;
 						do
 						{
 							// Look for the previous item in the toolbar.
-							next = item.previous;
+							next = next.previous;
 
 							// If it's the first item, cycle to the last one.
-							if ( !next )
+							if ( !next && toolbarGroupCycling )
 								next = item.toolbar.items[ item.toolbar.items.length - 1 ];
-
-							item = next;
 						}
-						while ( item && !item.focus )
+						while ( next && !next.focus )
 
 						// If available, just focus it, otherwise focus the
 						// last one.
-						if ( item )
-							item.focus();
+						if ( next )
+							next.focus();
 						else
 						{
-							var lastToolbarItems = editor.toolbox.toolbars[ editor.toolbox.toolbars.length - 1 ].items;
-							lastToolbarItems[ lastToolbarItems.length - 1 ].focus();
+							endFlag = 1;
+							// Send a SHIFT + TAB.
+							itemKeystroke( item, CKEDITOR.SHIFT + 9 );
+							endFlag = 0;
 						}
 
@@ -519,2 +528,14 @@
  * config.toolbarStartupExpanded = false;
  */
+
+/**
+ * When enabled, makes the arrow keys navigation cycle within the current
+ * toolbar group. Otherwise the arrows will move trought all items available in
+ * the toolbar. The TAB key will still be used to quickly jump among the
+ * toolbar groups.
+ * @name CKEDITOR.config.toolbarGroupCycling
+ * @type Boolean
+ * @default true
+ * @example
+ * config.toolbarGroupCycling = false;
+ */
