Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-13674

Modify createNavItem function in LinkBar component

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Later
    • Adobe Flex SDK Previous
    • None
    • mx: LinkBar
    • None
    • Language Found: English

    Description

      Current function "createNavItem" in LinkBar component accept only label and icon Class arguments. In my custom LinkBar component I cannot reused that function:
      1) New newLink:Button in my code has more attributes. To assign these attributes I need to know dataProvider index. var data:Object = dataProvider[index]
      2) In some cases I don't need separator between buttons. I tried to set style separatorSkin=null it does not help.

      My suggestion to change current function and assign more attributes:

      override protected function createNavItem(
      dataIndex:int,
      label:String,
      icon:Class = null,
      showSeparator = true):IFlexDisplayObject

      in SDK:

      override protected function createNavItem(
      label:String,
      icon:Class = null):IFlexDisplayObject

      { // Create the new LinkButton. var newLink:Button = Button(navItemFactory.newInstance()); newLink.styleName = this; if (label && label.length > 0) newLink.label = label; else newLink.label = " "; if (icon) newLink.setStyle("icon", icon); addChild(newLink); newLink.addEventListener(MouseEvent.CLICK, clickHandler); // Create the new separator to the left of the LinkButton. var separatorClass:Class = Class(getStyle("separatorSkin")); var separator:DisplayObject = DisplayObject(new separatorClass()); separator.name = SEPARATOR_NAME + (numChildren - 1); if (separator is ISimpleStyleClient) ISimpleStyleClient(separator).styleName = this; rawChildren.addChild(separator); return newLink; }

      Workarounds:

      1) I can hide separator if will assign separatorWidth = 0
      2) I can find child component iterating children, BUT that will work ONLY if icon and label are unique.
      var button:Button = super.createNavItem(label, icon) as Button;
      var numViews:int = targetStack.numChildren;
      for (var i:int = 0; i < numViews; i++){
      var child:Container = Container(targetStack.getChildAt);
      if(itemToLabel(child) == button.label && child.icon == button.getStyle('icon'))

      { button.data = child.data; break; }

      }

      Attachments

        Activity

          People

            adobejira Adobe JIRA
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: