Example #1
0
        /// <summary>
        /// Set the popup menu for this item.
        /// </summary>
        /// <param name="popup">
        /// popupmenu window to attach to this item
        /// </param>
        /// <param name="addAsChild"></param>
        protected void SetPopupMenuImpl(PopupMenu popup, bool addAsChild = true)
        {
            // is it the one we have already ?
            if (popup == _popup)
            {
                // then do nothing;
                return;
            }

            // keep the old one around
            var oldPopup = _popup;

            // update the internal state pointer
            _popup  = popup;
            _opened = false;

            // is there already a popup ?
            if (oldPopup != null)
            {
                RemoveChild(oldPopup);

                // should we destroy it as well?
                if (oldPopup.IsDestroyedByParent())
                {
                    // then do so
                    WindowManager.GetSingleton().DestroyWindow(oldPopup);
                }
            }

            // we are setting a new popup and not just clearing. and we are told to add the child
            if (popup != null && addAsChild)
            {
                AddChild(popup);
            }

            Invalidate(false);
        }
Example #2
0
 /// <summary>
 /// Set the popup menu for this item.
 /// </summary>
 /// <param name="popup">
 /// popupmenu window to attach to this item
 /// </param>
 public void SetPopupMenu(PopupMenu popup)
 {
     SetPopupMenuImpl(popup);
 }