Library/PackageCache/com.unity.quicksearch@1.6.0-preview.8/Editor/QuickSearch.cs
/// <summary>
/// Show a contextual menu for the specified item.
/// </summary>
/// <param name="item">Item affected by the contextual menu.</param>
/// <param name="position">Where the menu should be drawn on screen (generally item position)</param>
Show a contextual menu for the specified item.
Show a contextual menu for the specified item .
public void ShowItemContextualMenu(SearchItem item, Rect position)
        {
            var menu = new GenericMenu();
            var shortcutIndex = 0;
            var currentSelection = new[] { item };
            foreach (var action in item.provider.actions.Where(a => a.enabled(currentSelection)))
            {
                var itemName = action.content.tooltip;
                if (shortcutIndex == 0)
                {
                    itemName += " _enter";
                }
                else if (shortcutIndex == 1)
                {
                    itemName += " _&enter";
                }
                else if (shortcutIndex == 2)
                {
                    itemName += " _&%enter";
                }
                else if (shortcutIndex == 3)
                {
                    itemName += " _&%#enter";
                }
                menu.AddItem(new GUIContent(itemName, action.content.image), false, () => ExecuteAction(action, currentSelection));
                ++shortcutIndex;
            }
            if (position == default)
                menu.ShowAsContext();
            else
                menu.DropDown(position);
        }
public void ShowItemContextualMenu ( SearchItem item , Rect position ) { var menu = new GenericMenu ( ) ; var shortcutIndex = 0 ; var currentSelection = new [ ] { item } ; foreach ( var action in item . provider . actions . Where ( a => a . enabled ( currentSelection ) ) ) { var itemName = action . content . tooltip ; if ( shortcutIndex == 0 ) { itemName += " " ; } else if ( shortcutIndex == 1 ) { itemName += " " ; } else if ( shortcutIndex == 2 ) { itemName += " " ; } else if ( shortcutIndex == 3 ) { itemName += " " ; } menu . AddItem ( new GUIContent ( itemName , action . content . image ) , false , ( ) => ExecuteAction ( action , currentSelection ) ) ; ++ shortcutIndex ; } if ( position == default ) menu . ShowAsContext ( ) ; else menu . DropDown ( position ) ; }
Show a contextual menu for the specified item.
Show a contextual menu for the specified item .
item
SearchItem
Item affected by the contextual menu.
Item affected by the contextual menu .
position
Rect
None