ENB: Improving popup menus

39 views
Skip to first unread message

Edward K. Ream

unread,
Mar 24, 2020, 9:14:37 AM3/24/20
to leo-editor
This is #1531, which arises from a less-than-perfect fix for #1286.

This post describes the details and choices. But first, a summary of my plans...

Plans

It's too late to complete #1531 for Leo 6.2 final. It has been rescheduled for Leo 6.3.

For 6.2, I will add items to @data contextmenu-commands in leoSettings.leo. These items will create cut/copy/paste/select-all text items popup menus. These items will be added in the 6.2 branch, and merged into devel.

The "popup" branch will contain all code changes for 6.3. This branch is based on devel. The popup branch will not be merged into 6.2.

Background

I completed #1286 without a great deal of thought. My reasoning was that popups containing cut/copy/paste/select-all text popups were almost useless. Better to add outline-oriented commands everywhere. Several people have questioned this choice.

This is the kind of apparently trivial fit-and-finish issue that newbies often use to evaluate the "worth" of an app. They see something like this and start pontificating :-) Yes, it's ridiculous, but it's a fact of life. So something must be done...

Specifying popup items

1. Users can specify additional entries for the popup menu using @data contextmenu-commands. At present, the default, in leoSettings.leo, is:

# Important: the contextmenu.py plugin must be enabled for these settings to take effect.

# Add commands to contextmenu
# The format is <command> SPACE <description>

copy
-node Copy Node
cut
-node Cut Node
paste
-node Paste Node
paste
-retaining-clones Paste Node As Clone

2. The contextmenu plugin itself adds a set of "standard" items.

There is a buglet in this code that I will correct for 6.2. The old code added a "Delete" item. It should be labelled "Delete Node".

3. Finally, other plugins can add items to the list.

At present, the (misnamed) g.tree_popup_handlers list contains entries for all entries. I forget when items get added to this list. The load order of plugins is likely significant.

Choices

Vitalije and I have been considering whether there should be two popup menus: one for the tree, and one for the body.

Imo, this will create needless complexity. With proper labels, it should be clear which popup items apply to the outline and which apply to the body (or other text widgets). Furthermore, I see no reason ever to hide one set of commands.

Vitalije suggests putting outline commands first when the outline pane has focus, and putting body commands first otherwise. It's a reasonable suggestion, but it would create lots of behind-the-scenes complexities because now all specifications must include tree/body switch. This is not worth doing, imo. Neither newbies nor anyone else will swoon with delight. Probably, nobody will even notice. It doesn't add to Leo's perceived quality :-)

My Goals

1. At present, the contextmenu plugin specifies default entries for the pop menu. This is silly. Probably all standard entries can be specified by adding entries to the @data setting.

2. The @data setting should allow the user to specify separators in the popup menu.

3. (Probably not) The @data setting might allow the user to specify sub-menus in the popup menu.

At present, the todo.py plugin adds the Task sub menu. It would take considerable work to allow users to specify sub menus.

4. Show plugins-defined popup items after user-defined items, with a menu separator between them.

This will require a new global list, say g.plugins_popup_handlers.

Summary

6.2 will contain new items in @data contextmenu-commands for common text oriented commands. That should satisfy most users.

All code changes will be deferred to Leo 6.3. The "popup" branch will hold the work.

Imo, using the same popup for all panes is plenty good enough. This change is not worth extra code complexity.

All comments welcome.

Edward

Edward K. Ream

unread,
Mar 24, 2020, 11:11:30 AM3/24/20
to leo-editor
On Tuesday, March 24, 2020 at 8:14:37 AM UTC-5, Edward K. Ream wrote:

For 6.2, I will add items to @data contextmenu-commands in leoSettings.leo. These items will create cut/copy/paste/select-all text items popup menus. These items will be added in the 6.2 branch, and merged into devel.

This plan did not survive first contact with the code.

The configuredcommands_rclick function in contextmenu.py does not work as is with cut/copy/paste-text. These commands require an event arg which the callback must create. The necessary change should be safe enough, but it's uncomfortably late.

Edward

vitalije

unread,
Mar 24, 2020, 11:53:38 AM3/24/20
to leo-editor
Deleting the two lines in leo/plugins/qt_text.py in the LeoQTextBrowser.__init__ method:
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.onContextMenu)

Will revert to the old style. Context menu in the body would have standard commands like Cut, Copy, Paste,...

Vitalije

Edward K. Ream

unread,
Mar 24, 2020, 12:12:26 PM3/24/20
to leo-editor
On Tuesday, March 24, 2020 at 10:11:30 AM UTC-5, Edward K. Ream wrote:

The configuredcommands_rclick function in contextmenu.py does not work as is with cut/copy/paste-text. These commands require an event arg which the callback must create. The necessary change should be safe enough, but it's uncomfortably late.

I have just closed #1531. Imo, there is no need for further work.

New code will be part of 6.2. The new code is in the 6.2 and devel branches. The "popup" branch has been deleted. It was never used.

The new way is much better than all previous versions. You should be able to add any Leo command to the popup menu described by @data contextmenu-commands. You can also add menu separators by adding a line containing only "-".

Please test and report any problems.

Edward
Reply all
Reply to author
Forward
0 new messages