Help -- Idea for a UI addition

66 views
Skip to first unread message

tfer

unread,
Jul 10, 2016, 2:21:49 PM7/10/16
to leo-editor
As I fumbled around in Leo Menus trying to do half remembered things, (its been a while since I've used it), I thought that we should borrow from the prompts Inkscape provides to make this easier.

In Inkscape, down in the status bar context sensitive hints are displayed.  For instance, as you go through the menus, you get an explanation of what the currently highlighted menu item would do.  For Leo, say we have Edit > Edit Body > highlighted: 
  • "Create a new node named by the first line of selected body text and a body made of the other selected lines, then deletes that selection."
    • (if some lines are selected in an active body pane)
  • "Create a new node named the line the cursor is in (leading whitespace stripped)"
    • (for when we have the cursor or a selection in a single line)
  • "Needs to have cursor in, or lines selected in an active body pane to work"
    • (for when menu item is inactive)
This would make Leo easier to use

Terry Brown

unread,
Jul 10, 2016, 9:23:53 PM7/10/16
to leo-e...@googlegroups.com
On Sun, 10 Jul 2016 11:21:48 -0700 (PDT)
"'tfer' via leo-editor" <leo-e...@googlegroups.com> wrote:

> As I fumbled around in Leo Menus trying to do half remembered things,
> (its been a while since I've used it), I thought that we should
> borrow from the prompts Inkscape provides to make this easier.
>
> In Inkscape, down in the status bar context sensitive hints are

I think putting these hints in the status bar might be doable.

Inkscape is Gtk based. The idea of tooltips for menu items in Leo came
up some time ago, and I don't think it's directly supported in Qt.

https://wiki.qt.io/Qt_project_org_faq#How_can_I_add_tooltips_to_actions_in_menus.3F
(from an old thread "Re: Rev 5685: Docstrings create tooltips for
@button nodes, not @rclick nodes")

Not finding it but I think there was some proof of concept which was
considered too weird looking, but it used pop up tool tips near the
menu item, not the text in the status bar Inkscape uses.

So basically the method in that link could show the tips, if they
existed. I'm not sure if they do, in some cases (all cases?) a command
points to a function, and in some cases the doc. string for that
function would make good status bar text, but probably not always.

Still, the UI part's probably not hard.

Cheers -Terry

> displayed. For instance, as you go through the menus, you get an
> explanation of what the currently highlighted menu item would do.
> For Leo, say we have Edit > Edit Body > highlighted:
>
> - "Create a new node named by the first line of selected body text
> and a body made of the other selected lines, then deletes that
> selection."
> - (if some lines are selected in an active body pane)
> - "Create a new node named the line the cursor is in (leading
> whitespace stripped)"
> - (for when we have the cursor or a selection in a single line)
> - "Needs to have cursor in, or lines selected in an active body
> pane to work"
> - (for when menu item is inactive)

Largo84

unread,
Jul 11, 2016, 8:47:51 AM7/11/16
to leo-editor
I agree this would be great! I have no idea what most of the menu items do. It makes me wonder that I'm using only a small fraction of the capabilities of this terrific tool.

Rob............

Segundo Bob

unread,
Jul 11, 2016, 11:33:18 AM7/11/16
to leo-e...@googlegroups.com
On 07/10/2016 06:23 PM, 'Terry Brown' via leo-editor wrote:
> The idea of tooltips for menu items in Leo came
> up some time ago, and I don't think it's directly supported in Qt.

Terry,

Qt does support tooltips for menu items. I use this feature often. The
tooltip is displayed when you mouse over the menu item.

actTDL = QtWidgets.QAction(sc + labelValueHint.label, self)
if hint is not None:
actTDL.setToolTip(labelValueHint.hint)


--
Segundo Bob
Segun...@gmail.com

Terry Brown

unread,
Jul 11, 2016, 12:16:11 PM7/11/16
to leo-e...@googlegroups.com
On Mon, 11 Jul 2016 08:33:14 -0700
Segundo Bob <segun...@gmail.com> wrote:

> On 07/10/2016 06:23 PM, 'Terry Brown' via leo-editor wrote:
> > The idea of tooltips for menu items in Leo came
> > up some time ago, and I don't think it's directly supported in Qt.
>
> Terry,
>
> Qt does support tooltips for menu items. I use this feature often.
> The tooltip is displayed when you mouse over the menu item.

Ok, thanks, it was a while back and I don't remember exactly what the
issue was, I know someone possibly me got something working, but it
seemed the "use descriptive menu names" argument was the cleanest
option.

Discussion might have been just for @button menu @rclick nodes and not
the "system" menus.

Cheers -Terry

Terry Brown

unread,
Jul 11, 2016, 1:25:48 PM7/11/16
to leo-e...@googlegroups.com
On Mon, 11 Jul 2016 08:33:14 -0700
Segundo Bob <segun...@gmail.com> wrote:

Hmm, this wasn't working for me in Qt 4 or 5. The tool tip never
appears, and the info. at
https://wiki.qt.io/Qt_project_org_faq#How_can_I_add_tooltips_to_actions_in_menus.3F
seems correct.

Following the subclass and intercept event path from the above link, I
also notice that there's a significant delay in the tool-tip even
firing, which might not be ideal for tfer's "browsing functionality"
use case. Fix for the delay seems to be to use the on-enter event or
mouse tracking, but that's tricky for menu items because they're not
first class widgets.

Cheers -Terry

Segundo Bob

unread,
Jul 11, 2016, 2:43:34 PM7/11/16
to leo-e...@googlegroups.com
Terry,

I don't know anything about previous discussions.

Apparently there are no tooltips for the current Leo-Editor menus.

I use tooltips on the menus that I create and I think they work very well.


--
Segundo Bob
Segun...@gmail.com

rengel

unread,
Jul 12, 2016, 1:21:18 AM7/12/16
to leo-editor
Inkscape is Gtk based.  The idea of tooltips for menu items in Leo came
up some time ago, and I don't think it's directly supported in Qt.


Qt directly supports statusTips. 

Reinhard

Terry Brown

unread,
Jul 12, 2016, 9:38:03 AM7/12/16
to leo-e...@googlegroups.com
Ah, excellent, thanks, would have been a shame to implement it without
noticing that :-) And there's no delay in this event firing the way
there is with tool tips, so it works much better for browsing menu
functionality.

So now we just need to identify a source of useful tips. I think the
@menu tree could carry them, or they could come from the doc. string of
the function the menu fires. Don't want repeated descriptions in two
different places, but suspect the appropriate one liners might be
easier to collect in the @menu tree.

Cheers -Terry

Edward K. Ream

unread,
Jul 12, 2016, 4:52:47 PM7/12/16
to leo-editor
On Tue, Jul 12, 2016 at 8:37 AM, 'Terry Brown' via leo-editor <leo-e...@googlegroups.com> wrote:

Ah, excellent, thanks, would have been a shame to implement it without
noticing that :-)  And there's no delay in this event firing the way
there is with tool tips, so it works much better for browsing menu
functionality.

​An excellent collaboration so far.​
 

So now we just need to identify a source of useful tips.  I think the
@menu tree could carry them, or they could come from the doc. string of
the function the menu fires.  Don't want repeated descriptions in two
different places, but suspect the appropriate one liners might be
easier to collect in the @menu tree.

​There are some issues to be dealt with.  For sure, the statusTips should be a single line.  They should probably be created ​in the same place that creates the actual menu items, namely createMenuEntries (in leoMenu.py) and its helpers.

The question is, what should the text be, and where to get it?  Defining text in the @menu tree would duplicate some of the text of help-for-command (F11).  The text in the @menu tree would easily get out of sync with the F11 text.

So I think my preference is to have all command docstrings start with a single line that will become the statusTips text for the menu item
​ corresponding to the command​
.
​ The only question is whether the docstring ca​
​n be obtained quickly enough.  I think it can.​


It would be straightforward to write a script to print the docstrings for all functions/methods with
​ ​
@cmd or @g.command
​ decorators.​ Actually, a similar script already exists in scripts.leo:

@file leoScripts.txt-->Docstrings-->Print commands & docstrings

This would be a starting point for startup code that would discover all statusTips.

Edward

Reply all
Reply to author
Forward
0 new messages