Position the experimental, optional right-click context menu so a left click will paste #20272

Open
opened 2026-01-31 07:08:42 +00:00 by claunia · 2 comments
Owner

Originally created by @Jaykul on GitHub (Jul 22, 2023).

Description of the new feature/enhancement

As a terminal user
When I right-click and get a menu
I want "Paste" to be the default option that appears directly where my mouse is

Proposed technical implementation details (optional)

The menu should always open such that the paste icon is directly below the cursor, instead of sometimes slightly above and to the right, and sometimes slightty above and to the left.

Do you realize the behavior is inconsistent?

  • The first time I right click, it opens with the cursor just to the left of the the line between the buttons and the text menu items.
  • If you right-click elsewhere while the menu is open, it moves to be horizontally centered on the mouse
  • If you right-click on the menu (and then move your mouse off the menu), you get the window's title-bar context menu
Originally created by @Jaykul on GitHub (Jul 22, 2023). # Description of the new feature/enhancement As a terminal user When I right-click and get a menu I want "Paste" to be the default option that appears directly where my mouse is # Proposed technical implementation details (optional) The menu should always open such that the paste icon is directly below the cursor, instead of sometimes slightly above and to the right, and sometimes slightty above and to the left. ## Do you realize the behavior is inconsistent? - The first time I right click, it opens with the cursor just to the _left_ of the the line between the buttons and the text menu items. - If you right-click **elsewhere** _while the menu is open_, it moves to be horizontally centered on the mouse - If you right-click **on** the menu (and then move your mouse off the menu), you get the window's title-bar context menu
claunia added the Help WantedIssue-TaskProduct-TerminalArea-TerminalControl labels 2026-01-31 07:08:43 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 24, 2023):

This isn't a bad idea at all. Though, I'll say that we should try and position it so that the first Primary button is under the cursor. That way, opening the menu with a selection would start with "copy" under the mouse.

Note

Walkthrough

I'd take a look at TermControl::_contextMenuHandler and TermControl::_showContextMenuAt. Those are what's responsible for opening our context menu. We should be able to slightly shift it.

Though, the direction we shift it might have to change based on the bounds of the control itself... Hmm. Right now we just ask WinUI to open the flyout at the point of the cursor, and let it adjust the positioning to account for the boundaries of the monitors.

I'm actually not gonna tag this up as a walkthrough after all, because this seems hard to get right.

If you maximize, then click near the bottom of the window (so that the menu needs to open
upwards, well, WinUI just gives up and doesn't bother with the centering anymore. Even if there's space for the primary commands between the cursor and the bottom of the display.


If you right-click on the menu (and then move your mouse off the menu), you get the window's title-bar context menu

lmao that's actually this hilarious XAML bug. If you right click on the shadow of any flyout, you get a system context menu. Literally makes no sense 🤣

@zadjii-msft commented on GitHub (Jul 24, 2023): This isn't a bad idea at all. Though, I'll say that we should try and position it so that the _first_ Primary button is under the cursor. That way, opening the menu with a selection would start with "copy" under the mouse. > **Note** > ## ~Walkthrough~ I'd take a look at `TermControl::_contextMenuHandler` and `TermControl::_showContextMenuAt`. Those are what's responsible for opening our context menu. We should be able to slightly shift it. Though, the direction we shift it might have to change based on the bounds of the control itself... Hmm. Right now we just ask WinUI to open the flyout at the point of the cursor, and let it adjust the positioning to account for the boundaries of the monitors. I'm actually _not_ gonna tag this up as a walkthrough after all, because this seems hard to get right. > If you maximize, then click near the bottom of the window (so that the menu needs to open upwards, well, WinUI just gives up and doesn't bother with the centering anymore. Even if there's space for the primary commands between the cursor and the bottom of the display. --- > If you right-click on the menu (and then move your mouse off the menu), you get the window's title-bar context menu lmao that's actually this _hilarious_ XAML bug. If you right click on the _shadow_ of any flyout, you get a system context menu. Literally makes no sense 🤣
Author
Owner

@Jaykul commented on GitHub (Jul 25, 2023):

This isn't a bad idea at all. Though, I'll say that we should try and position it so that the first Primary button is under the cursor. That way, opening the menu with a selection would start with "copy" under the mouse.

You're absolutely right. This is the way.

Though, the direction we shift it might have to change based on the bounds of the control itself... Hmm. Right now we just ask WinUI to open the flyout at the point of the cursor, and let it adjust the positioning to account for the boundaries of the monitors.

It's true that if someone clicks too close to the edge, the menu might not fit entirely on screen if you blindly positioned it as I was suggesting. Personally, I'd still like it there (as long as that first item is on screen, it'll be fine 😉), but I can see that's not an ideal default.

@Jaykul commented on GitHub (Jul 25, 2023): > This isn't a bad idea at all. Though, I'll say that we should try and position it so that the _first_ Primary button is under the cursor. That way, opening the menu with a selection would start with "copy" under the mouse. You're absolutely right. This is the way. > Though, the direction we shift it might have to change based on the bounds of the control itself... Hmm. Right now we just ask WinUI to open the flyout at the point of the cursor, and let it adjust the positioning to account for the boundaries of the monitors. It's true that if someone clicks _too_ close to the edge, the menu might not fit entirely on screen if you blindly positioned it as I was suggesting. Personally, I'd still like it there (as long as that first item is on screen, it'll be _fine_ 😉), but I can see that's not an ideal default.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20272