 
     /**
      *  @private
-     *  Called when an item has been added to this component.
-     */
-    private function dataGroup_rendererAddHandler(event:RendererExistenceEvent):void
-    {
-        var renderer:IVisualElement = event.renderer; 
-        var index:int = event.index;
-        
-        if (renderer)
-        {
-            renderer.addEventListener(MouseEvent.CLICK, item_clickHandler);
-            if (renderer is IFocusManagerComponent)
-                IFocusManagerComponent(renderer).focusEnabled = false;
-            if (renderer is ButtonBarButton)
-                ButtonBarButton(renderer).allowDeselection = !requireSelection;
-        }
-    }
-    
-    /**
-     *  @private
-     *  Called when an item has been removed from this component.
-     */
-    private function dataGroup_rendererRemoveHandler(event:RendererExistenceEvent):void
-    {        
-        var renderer:IVisualElement = event.renderer;
-        
-        if (renderer)
-            renderer.removeEventListener(MouseEvent.CLICK, item_clickHandler);
-    }
-    
-    /**
-     *  @private
-     *  Called when an item is clicked.
-     */
-    private function item_clickHandler(event:MouseEvent):void
-    {
-        var newIndex:int
-        if (event.currentTarget is IItemRenderer)
-            newIndex = IItemRenderer(event.currentTarget).itemIndex;
-        else
-            newIndex = dataGroup.getElementIndex(event.currentTarget as IVisualElement);
-
-        var currentRenderer:IItemRenderer;
-        if (caretIndex >= 0 && !inKeyUpHandler) // don't remove caret when keybd nav
-        {
-            currentRenderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
-            currentRenderer.showsCaret = false;
-        }
-
-        if (newIndex == selectedIndex)
-        {
-            if (!requireSelection)
-                selectedIndex = NO_SELECTION;
-        }
-        else
-        {
-            selectedIndex = newIndex;
-        }
-
-    }
-    
-    /**
-     *  @private
-     */
-    private function caretChangeHandler(event:Event):void
-    {
-        adjustLayering(caretIndex);
-    }
-
-    /**
-     *  @private
-     */
-    override protected function keyDownHandler(event:KeyboardEvent):void
-    {
-        var currentRenderer:IItemRenderer;
-        var renderer:IItemRenderer;
-        
-        if (event.eventPhase == EventPhase.BUBBLING_PHASE)
+     *  button bar always keeps something under the caret so don't let it
+     *  become -1
+     */
+    override mx_internal function setCurrentCaretIndex(value:Number):void
+    {
+        if (value == -1)
             return;
 
-        if (!enabled || !dataProvider || event.isDefaultPrevented())
-            return;
-        
-        super.keyDownHandler(event);
-
-        var oldCaretIndex:Number = caretIndex; 
-        var e:IndexChangeEvent;
-        var length:int = dataProvider.length;
-        switch (event.keyCode)
-        {
-            case Keyboard.UP:
-            case Keyboard.LEFT:
-            {
-                currentRenderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
-                if (caretIndex > 0 || arrowKeysWrapFocus)
-                {
-                    if (currentRenderer)
-                        currentRenderer.showsCaret = false;
-                    setCurrentCaretIndex((caretIndex - 1 + length) % length);
-                    adjustLayering(caretIndex);
-                    renderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
-                    if (renderer)
-                        renderer.showsCaret = true;
-                    e = new IndexChangeEvent(IndexChangeEvent.CARET_CHANGE); 
-                    e.oldIndex = oldCaretIndex; 
-                    e.newIndex = caretIndex; 
-                    dispatchEvent(e);    
-                }
-
-                event.preventDefault();
-                break;
-            }
-            case Keyboard.DOWN:
-            case Keyboard.RIGHT:
-            {
-                currentRenderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
-                if (caretIndex < dataProvider.length - 1 || arrowKeysWrapFocus)
-                {
-                    if (currentRenderer)
-                        currentRenderer.showsCaret = false;
-                    setCurrentCaretIndex((caretIndex + 1) % length);
-                    adjustLayering(caretIndex);
-                    renderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
-                    if (renderer)
-                        renderer.showsCaret = true;
-                    e = new IndexChangeEvent(IndexChangeEvent.CARET_CHANGE); 
-                    e.oldIndex = oldCaretIndex; 
-                    e.newIndex = caretIndex; 
-                    dispatchEvent(e);    
-                }
-
-                event.preventDefault();
-                break;
-            }            
-            case Keyboard.SPACE:
-            {
-                currentRenderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
-                if (!currentRenderer || (currentRenderer.selected && requireSelection))
-                    return;
-                currentRenderer.dispatchEvent(event);
-                break;
-            }            
-        }
-    }
-  
-    /**
-     *  @private
-     */
-    override protected function keyUpHandler(event:KeyboardEvent):void
-    {
-        var currentRenderer:IItemRenderer;
-        var renderer:IItemRenderer;
-
-        if (event.eventPhase == EventPhase.BUBBLING_PHASE)
-            return;
-
-        if (!enabled)
-            return;
-
-        inKeyUpHandler = true;
-
-        super.keyUpHandler(event);
-
-        switch (event.keyCode)
-        {
-            case Keyboard.SPACE:
-            {
-                  currentRenderer = dataGroup.getElementAt(caretIndex) as IItemRenderer;
-                if (!currentRenderer || (currentRenderer.selected && requireSelection))
-                    return;
-                currentRenderer.dispatchEvent(event);
-                break;
-            }            
-        }
-
-        inKeyUpHandler = false;
+        super.setCurrentCaretIndex(value);
+    }
+
+     /**
+     *  @private
+     *  Called by the initialize() method of UIComponent
+     *  to hook in the accessibility code.
+     */
+    override protected function initializeAccessibility():void
+    {
+        if (createAccessibilityImplementation != null)
+            createAccessibilityImplementation(this);
+    }
+
+
+    //--------------------------------------------------------------------------
+    //
+    //  Private Methods
+    //
+    //--------------------------------------------------------------------------
+
+    private function defaultButtonBarItemRendererFunction(data:Object):IFactory
+    {
+        var i:int = dataProvider.getItemIndex(data);
+        if (i == 0)
+            return firstButton ? firstButton : middleButton;
+
+        var n:int = dataProvider.length - 1;
+        if (i == n)
+            return lastButton ? lastButton : middleButton;
+
+        return middleButton;
     }
 }
 

     */
    public var middleButton:IFactory;

    //--------------------------------------------------------------------------
    //
    //  Overridden properties
    //
    //--------------------------------------------------------------------------


import flash.events.MouseEvent;
import flash.ui.Keyboard;

import spark.components.supportClasses.ButtonBarBase;
import spark.events.IndexChangeEvent;
import spark.events.RendererExistenceEvent;

