Add support for a right-click context menu#14775
Conversation
This comment has been minimized.
This comment has been minimized.
| // Only wire up "Close Pane" if there's multiple panes. | ||
| if (_GetFocusedTabImpl()->GetLeafPaneCount() > 1) | ||
| { | ||
| makeItem(RS_(L"ClosePaneContextMenuEntryText"), L"\xE89F", ActionAndArgs{ ShortcutAction::ClosePane, nullptr }); | ||
| } |
There was a problem hiding this comment.
I feel like guidance is that we should always include this option, but disable it if it can't be used. That way, the user can always see what options are available.
Ironically, ClosePane is still valid though, so maybe we shouldn't even disable/remove it at all haha.
Curious what others think
There was a problem hiding this comment.
My consideration was that when there's only one pane, closeTab == closePane. So putting closePane there, even if it's disabled, just adds noise. That's my thought. Furthermore, just doing closePane when there's only one pane might confuse people who don't get that there are panes (probably most people)
|
up next, once this and #14807 merge: dev/migrie/f/3337-just-for-funsies...dev/migrie/f/rclick-select-command |
DHowett
left a comment
There was a problem hiding this comment.
partway through (11/24) but I've got to go for now
| makeItem(RS_(L"SplitPaneText"), L"\xF246", ActionAndArgs{ ShortcutAction::SplitPane, SplitPaneArgs{ SplitType::Duplicate } }); | ||
| makeItem(RS_(L"DuplicateTabText"), L"\xF5ED", ActionAndArgs{ ShortcutAction::DuplicateTab, nullptr }); | ||
|
|
||
| // Only wire up "Close Pane" if there's multiple panes. |
There was a problem hiding this comment.
Design q: should we display this but leave it disabled?
There was a problem hiding this comment.
Given past conversations on the repo, I reckon that most users don't even know what a Pane is, so that might be confusing. I erred on the side of "display the fewest possible valid options".
I am open to being overruled, idgaf.
| ctrlEnabled && | ||
| !hyperlink.empty()) |
| { | ||
| // formats = nullptr -> copy all formats | ||
| _interactivity.CopySelectionToClipboard(false, nullptr); | ||
| ContextMenu().Hide(); |
There was a problem hiding this comment.
If somebody else provides the implementation of the command handler, how do THEY get to hide the menu?
There was a problem hiding this comment.
I suppose makeCallback could have called Hide itself. I guess I never hit that in selfhosting. Interesting...
DHowett
left a comment
There was a problem hiding this comment.
I believe your build failure is due to TerminalControl rolling up a duplicate copy of MUX (if i had to guess). Otherwise... looks good.
carlos-zamora
left a comment
There was a problem hiding this comment.
Approving, but not adding "Automerge" in case you want to go in and resolve my suggestions.
|
|
||
| runtimeclass ContextMenuRequestedEventArgs | ||
| { | ||
| Windows.Foundation.Point Point { get; }; |
There was a problem hiding this comment.
this is such a nit, but I don't like that it's a Point Point. Maybe rename it to Position?
| control->ContextMenu().PrimaryCommands().Clear(); | ||
| control->ContextMenu().SecondaryCommands().Clear(); | ||
| for (const auto& e : control->_originalPrimaryElements) | ||
| { | ||
| control->ContextMenu().PrimaryCommands().Append(e); | ||
| } | ||
| for (const auto& e : control->_originalSecondaryElements) | ||
| { | ||
| control->ContextMenu().SecondaryCommands().Append(e); | ||
| } |
There was a problem hiding this comment.
| control->ContextMenu().PrimaryCommands().Clear(); | |
| control->ContextMenu().SecondaryCommands().Clear(); | |
| for (const auto& e : control->_originalPrimaryElements) | |
| { | |
| control->ContextMenu().PrimaryCommands().Append(e); | |
| } | |
| for (const auto& e : control->_originalSecondaryElements) | |
| { | |
| control->ContextMenu().SecondaryCommands().Append(e); | |
| } | |
| auto& menu = control->ContextMenu(); | |
| menu.PrimaryCommands().Clear(); | |
| menu.SecondaryCommands().Clear(); | |
| for (const auto& e : control->_originalPrimaryElements) | |
| { | |
| menu.PrimaryCommands().Append(e); | |
| } | |
| for (const auto& e : control->_originalSecondaryElements) | |
| { | |
| menu.SecondaryCommands().Append(e); | |
| } |
| control->SelectionContextMenu().PrimaryCommands().Clear(); | ||
| control->SelectionContextMenu().SecondaryCommands().Clear(); | ||
| for (const auto& e : control->_originalSelectedPrimaryElements) | ||
| { | ||
| control->SelectionContextMenu().PrimaryCommands().Append(e); | ||
| } | ||
| for (const auto& e : control->_originalSelectedSecondaryElements) | ||
| { | ||
| control->SelectionContextMenu().SecondaryCommands().Append(e); | ||
| } |
There was a problem hiding this comment.
| control->SelectionContextMenu().PrimaryCommands().Clear(); | |
| control->SelectionContextMenu().SecondaryCommands().Clear(); | |
| for (const auto& e : control->_originalSelectedPrimaryElements) | |
| { | |
| control->SelectionContextMenu().PrimaryCommands().Append(e); | |
| } | |
| for (const auto& e : control->_originalSelectedSecondaryElements) | |
| { | |
| control->SelectionContextMenu().SecondaryCommands().Append(e); | |
| } | |
| auto& menu = control->SelectionContextMenu(); | |
| menu.PrimaryCommands().Clear(); | |
| menu.SecondaryCommands().Clear(); | |
| for (const auto& e : control->_originalSelectedPrimaryElements) | |
| { | |
| menu.PrimaryCommands().Append(e); | |
| } | |
| for (const auto& e : control->_originalSelectedSecondaryElements) | |
| { | |
| menu.SecondaryCommands().Append(e); | |
| } |
| _useRightClickContextMenu = settings.RightClickContextMenu(); | ||
|
|
There was a problem hiding this comment.
Do we use _useRightClickContextMenu anywhere? Why can't we call _settings.RightClickContextMenu() when we need it?
Adds
```
{ "command": "showContextMenu", "keys": "menu" },
```
as a default action. This will manually invoke the control context menu
(from #14775), even with the setting disabled.
As discussed with Dustin.
|
Would it be possible to allow the "See less" and "See more" to be persistent? At the moment, when I click "See less" it only stays while active, consecutive right-clicks show the expanded context menu |




Experimental for now.
experimental.rightClickContextMenu, a per-profile setting. Long term we want to enable full mouse bindings, at which point this would be replaced.Closes #3337
This adds two context menus to the
TermControl- one for right-clicking with a selection, and one without. The implementation is designed to follows the API experience of the context menu on something like aRichEditBox. The hosting application adds a handler for the menu'sOpeningevent, and appends whatever items it wants at that time.So
TermControlonly implements a few "actions" by default - copy, past, find.TerminalAppis then responsible for adding anything else it needs. Right now, those actions are:Screenshots in #14775 (comment)