Sublime Forum

Quick panel: show hint for item

#1

how to show a description for items in the quick panel, like the key combos in the command pallette:

0 Likes

#2

As seen in your screenshot, the command palette will show you the current key binding for commands in the palette that are bound to at least one key binding. If you were to create a sublime-commands file to include other commands, you can use \t in the caption field to apply a custom hint.

[
    {
        "caption": "My Command\ttip here",
        "command": "echo"
    }
]

However, this doesn’t work in a quick panel; as far as I’m aware it’s not possible to do that. However the window.show_quick_panel() API method allows you to provide a list of lists, in which case each item in the resulting quick panel will have multiple rows, so you can provide hints that way.

items = [["First", "The first item"], ["Second", "The second item"]]
window.show_quick_panel(items, on_select=None)

0 Likes

#3

Thanks @OdatNurd, that’s a shame, it’s useful to be able to specify a hint, if only

items = [["First\tfirsthint", "The first item"], ["Second\tsecondhint", "The second item"]]
window.show_quick_panel(items, on_select=None)

did the trick, that will be very useful !

0 Likes

#4

is there a way to show a hint under the item for ListInputHandler ?

0 Likes

#5

Not directly, I don’t think.

However if you implement the preview() method in your input handler, the text that it returns will be displayed below all of the list items. The method gets called every time the selected item changes (and gets passed the item currently selected), so you can provide hints for items as they’re selected, just not all at once.

Also, in that case since the captions are being displayed in the command palette you can append a tab (\t) followed by hint text just like in the caption I outlined above, and then the items in the palette will show the hint directly.

Note however that if you do that, the text of the hint will also be added to the selected item; you can either split it away or return a list of tuple from list_items() to separate what’s displayed in the palette from what the value is when it’s selected.

0 Likes

#6

Thanks @OdatNurd, Thats what I was looking for sinse the beginning, I already tried that with the quick_panel ,it didn’t work so I didn’t try it for the ListInputHandler. Thanks again for the help :smiley: .

0 Likes