protected override void ChildAdded(DisplayListMember child) { //Debug.Log("GroupBase - ChildAdded: " + child); if (HasEventListener("childrenChanged")) { DispatchEvent(new Event("childrenChanged")); } if (HasEventListener(ChildExistenceChangedEvent.CHILD_ADD)) { var cece = new ChildExistenceChangedEvent(ChildExistenceChangedEvent.CHILD_ADD) { RelatedObject = child }; DispatchEvent(cece); } /*if (child is ModalOverlay) * Debug.Log("Added: " + child);*/ if (child.HasEventListener(FrameworkEvent.ADD)) { child.DispatchEvent(new FrameworkEvent(FrameworkEvent.ADD)); } base.ChildAdded(child); }
private void ChildAddHandler(Event e) { ChildExistenceChangedEvent cece = (ChildExistenceChangedEvent)e; var child = cece.RelatedObject; var index = GetChildIndex(child); //Debug.Log("ChildAddHandler: " + child); if (child is InteractiveComponent) { var uiChild = (InteractiveComponent)child; // ViewStack creates all of its children initially invisible. // They are made as they become the selected child. uiChild.Visible = false; //Debug.Log("Set invisible: " + uiChild); } //if (child is INavigatorContent) //{ // child.addEventListener("labelChanged", navigatorChildChangedHandler); // child.addEventListener("iconChanged", navigatorChildChangedHandler); //} // If we just created the first child and no selected index has // been proposed, then propose this child to be selected. if (NumberOfChildren == 1 && proposedSelectedIndex == -1) { SelectedIndex = 0; } else if (index <= _selectedIndex && NumberOfChildren > 1 && proposedSelectedIndex == -1) { SelectedIndex++; } }
private void ChildRemoveHandler(Event e) { ChildExistenceChangedEvent cece = (ChildExistenceChangedEvent)e; var child = cece.RelatedObject; var index = GetChildIndex(child); //if (child is INavigatorContent) //{ // child.removeEventListener("labelChanged", navigatorChildChangedHandler); // child.removeEventListener("iconChanged", navigatorChildChangedHandler); //} // Handle the simple case. if (index > _selectedIndex) { return; } var currentSelectedIndex = _selectedIndex; // This matches one of the two conditions: // 1. a view before the current was deleted, or // 2. the current view was deleted and it was also // at the end of the stack. // In both cases, we need to decrement selectedIndex. if (index < currentSelectedIndex || currentSelectedIndex == (NumberOfChildren - 1)) { // If the selectedIndex was already 0, it should go to -1. // -1 is a special value; in order to avoid runtime errors // in various methods, we need to skip the range checking in // commitSelectedIndex() and set _selectedIndex explicitly here. if (currentSelectedIndex == 0) { SelectedIndex = -1; _selectedIndex = -1; } else { SelectedIndex--; } } else if (index == currentSelectedIndex) { // If we're deleting the currentSelectedIndex and there is another // child after it, it will become the new selected child so we // need to make sure it is instantiated. _needToInstantiateSelectedChild = true; InvalidateProperties(); } }
protected override void RemovingChild(DisplayListMember child) { base.RemovingChild(child); if (child.HasEventListener(FrameworkEvent.REMOVE)) { child.DispatchEvent(new FrameworkEvent(FrameworkEvent.REMOVE)); } if (HasEventListener(ChildExistenceChangedEvent.CHILD_REMOVE)) { var cece = new ChildExistenceChangedEvent(ChildExistenceChangedEvent.CHILD_REMOVE) { RelatedObject = child }; DispatchEvent(cece); } }