Пример #1
0
        public void back()
        {
            MenuComponentComposite f = this.currentSelectedComponent.getFather();

            if (f == this.menu.getChild(0))
            {
                return;
            }
            try
            {
                if (!this.currentSelectedComponent.isExpanded() && this.currentSelectedComponent.hasFocus())
                {
                    this.currentSelectedComponent.setFocus(false);
                    f.getFather().setExpanded(true);
                    f.getFather().validate();
                    f.setExpanded(false);
                    this.currentSelectedComponent = f;
                    this.currentComponentIndex    = this.componentsTraversedIndexes.Pop();
                    f.setFocus(true);
                    //  this.currentSelectedComponent.setFocus(true);
                }
                else
                {
                    //should be a container expanded without child
                    //   Console.WriteLine("Closing container expanded without child");
                    this.currentSelectedComponent.setFocus(true);
                    this.currentSelectedComponent.setExpanded(false);
                    f.setExpanded(true);
                    f.validate();
                }
            }
            catch (NoChildException e)
            {
            }
        }
Пример #2
0
 new public void setFocus(bool state)
 {
     if (this.expanded)
     {
         MenuComponentComposite c = this.getChild(0);
         if (c != null && state == true)
         {
             c.setFocus(true);
         }
     }
     else
     {
         base.setFocus(state);
     }
 }
Пример #3
0
        public MenuTraverser(RootMenuItem menu)
        {
            this.menu = menu;
            //    this.OnMenuActionCachedHandler = (action) => this.OnMenuAction(action);

            this.componentsTraversedIndexes = new Stack <int>();
            MenuComponentComposite firstChild = this.menu.getChild(0);


            if (firstChild != null)
            {
                firstChild.setExpanded(true);

                this.currentSelectedComponent = firstChild;
                this.currentComponentIndex    = 0;

                MenuComponentComposite c = firstChild.getChild(0);
                //first child of the first child of root is a container with at least one child. Start traversing from here
                if (c != null)
                {
                    this.componentsTraversedIndexes.Push(this.currentComponentIndex);
                    this.currentSelectedComponent = c;
                    this.currentSelectedComponent.setFocus(true);
                    this.currentComponentIndex = 0;
                    // this.currentSelectedComponent.setExpanded(true);
                }
                else
                {
                    firstChild.setFocus(true);
                }
            }
            else
            {
                //that's pretty strange. a root component should always have a child component
            }
        }