You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Alt + select with mouse: editor looses the focus #12310
RStudio Edition : Desktop [Open Source]
RStudio Version : 2022.12.0.314
OS Version : Windows 10 x64 (build 19044)
R Version : R version 4.2.2 (2022-10-31 ucrt)
Steps to reproduce the problem
Open a file in RStudio's Editor that has several rows of text.
Select several rows of text while pressing Alt
Cannot do anything with text (e.g., copy it), as after releasing Alt, the editor loses focus. It seems that the focus is moved to the "File" menu:
Describe the problem in detail
Alt + Selecting several rows is inefficient now as it is not possible to do anything with the selected text, as the focus is lost.
Describe the behavior you expected
I expect the same behavior as in the current stable RStudio version 2002.07.2 while after releasing Alt the focus is not moved/lost.
Reacted by Desi Quintans, Rasmus Hertzum, Elizabeth Mitchell, ebein, nwbort, koenniem, Ron Togunov, Eduardo Ryô Tamaki, Dan Chaltiel, Bastien and 5 more
@GegznaV Does it work the first time you click on Alt, but then focus switches to the "File" menu? That's what I'm seeing both in 2022.07.2+576. And then clicking on Alt again returns focus. It's also typical of other applications, such as Notepad, WordPad, and Slack.
Focus is lost after Alt is released. No issue with this in Notepad++, VSCode, RStudio 2022.07.2, but there's a problem in RStudio daily builds (now I have 2022.12.0.318).
You may notice in the gif, that Delete first time has no effect on the selection:
After pressing Alt once more it seems that the focus is back. But it is inconvenient as for operations that have no visible effects such as Ctrl+C it is not clear if the action was performed successfully or not as extra attention should be paid where the focus is. It was not the case in the previous RStudio version.
It seems that some new functionality clashes with the old functionality.
Did any new option appear in RStudio, that enabled Alt to change focus?
The issue is that in the new version of RStudio, clicking Alt automatically selects File menu in the main menu bar (next, you can use Tab key to navigate to the following menu options, or e.g., Alt + F to expand files menu, find gif below). Is there an option to suppress this new behaviour of Alt?
@ronblum , is the new behaviour of the Alt button different with RStudio 2022.12.0+353 Elsbeth Geranium (desktop) on your computer than the one shown in the GIF and described above as you added the label that repro needed? Does repro needed mean that this behaviour is unique to my computer only?
I have just noticed, that the behaviour I want (not to lose focus) can also be achieved by clicking and holding Alt + Shift.
But it is confusing, as by clicking and holding Alt, a cross-hair appears, indicating that the same behaviour could be achieved just by holding Alt. So the other option could be to remove the multiline selection option when only Alt is held (this is the case in, e.g., VSCode: here only Alt + Shift allows choosing multiple rows from the same row position).
Reacted by asadow, Ron Togunov, lekxens and Cortalak
Is this problem fixed? I'm on 2023.03.0+386 and this problem popped up. The only bypass is this sequence: ctrl -> alt -> press shift (or other buttons, so far just backpsace and s, don't do escape) and let go -> left click and place cursor where you want it.
It's weird but works for me. I found this after some testing for key glitches. At some point in time I was able to use shift+alt to get multi cursor to work in this version, but somehow it disappeared. Very bugged. Hope they fix it, multi cursor is a staple function lol.
I'm still having this issue with the most recent version of RStudio, but the Shift + Alt suggestion earlier in the thread seems to be working (at least for the first day I've tried it).
RStudio 2023.06.0+421 "Mountain Hydrangea" Release (583b465, 2023-06-05) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.0+421 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36
Personally, and Im sure others have the issue, it just doesnt make sense to update to the latest RStudios where my workflow will take a hit unless its just never going to happen and Ill just have to accept it and deal with it.
Implementing #8932 might work around the issue as some have reported Electron apps that hide the menu bar will no longer immediately change focus. Short of disabling the Alt behaviour with some custom handling and logic, this is likely to wait on an Electron change. Any change here must ensure that keyboard navigation can activate menus while still allowing Alt to column select text in the editor.
For those on Windows, another (very Jankey) workaround using Autohotkey is to trigger "right click" and "escape" whenever you press click+ alt
Took me forever to figure out something that works and doesn't interfere with other functions (eg multicursor).
Here is code using AutoHotKey V2
; multi-line select
#HotIf WinActive("ahk_exe rstudio.exe") ; ensures triggers only applied when in Rstudio window
~LButton & LAlt::{ ; trigger. "~" permits native function of click+alt (i.e., doesn't hide input from system)
KeyWait "LButton" ; wait for release of left click
KeyWait "LAlt" ; wait for release of left alt
send "{RButton}{Esc}" ; sends right click and escape
}
#HotIf
Note: I opted for right-click+escape because Rstudio doesn't always lose focus from console with multi-line selection, in which case sending {alt} would inadvertently shift focus to menu bar and {esc} would cancel the selection.
No, unfortunately not. My workflow has now changed to "release Alt key and press Alt key again" to unfocus the menu and instead return the focus to script window. :-/
Activity
ronblum commentedon Nov 9, 2022
@GegznaV Does it work the first time you click on Alt, but then focus switches to the "File" menu? That's what I'm seeing both in 2022.07.2+576. And then clicking on Alt again returns focus. It's also typical of other applications, such as Notepad, WordPad, and Slack.
GegznaV commentedon Nov 9, 2022
Focus is lost after Alt is released. No issue with this in Notepad++, VSCode, RStudio 2022.07.2, but there's a problem in RStudio daily builds (now I have 2022.12.0.318).
You may notice in the gif, that Delete first time has no effect on the selection:
After pressing Alt once more it seems that the focus is back. But it is inconvenient as for operations that have no visible effects such as Ctrl+C it is not clear if the action was performed successfully or not as extra attention should be paid where the focus is. It was not the case in the previous RStudio version.
It seems that some new functionality clashes with the old functionality.
Did any new option appear in RStudio, that enabled Alt to change focus?
GegznaV commentedon Nov 9, 2022
@ronblum, can you reproduce the
Alt(hold) → Select → Alt(release) → Delete → Nothing happenssequence or behavior is different for you?Can you confirm that the behavior is the same on both stable and daily builds RStudio versions for you?
rjvelasquezm commentedon Nov 9, 2022
FWIW I see this same behavior (described here #12231 (comment)) when testing the electron build.
GegznaV commentedon Dec 14, 2022
The issue is that in the new version of RStudio, clicking

Altautomatically selectsFilemenu in the main menu bar (next, you can useTabkey to navigate to the following menu options, or e.g.,Alt+Fto expand files menu, find gif below). Is there an option to suppress this new behaviour ofAlt?@ronblum , is the new behaviour of the
Altbutton different with RStudio 2022.12.0+353 Elsbeth Geranium (desktop) on your computer than the one shown in the GIF and described above as you added the label thatrepro needed? Doesrepro neededmean that this behaviour is unique to my computer only?I have just noticed, that the behaviour I want (not to lose focus) can also be achieved by clicking and holding
Alt+Shift.But it is confusing, as by clicking and holding
Alt, a cross-hair appears, indicating that the same behaviour could be achieved just by holdingAlt. So the other option could be to remove the multiline selection option when onlyAltis held (this is the case in, e.g., VSCode: here onlyAlt+Shiftallows choosing multiple rows from the same row position).kevinushey commentedon Dec 15, 2022
Just to confirm, with this sequence of actions: "press and holt Alt, click the mouse to make a multi-cursor selection; release Alt"
In both builds, pressing Alt alone does send focus to the main menu bar (as expected).
As I understand it, clicking the mouse while Alt is held down should "cancel" the "send focus to main menu bar" action, but that's not happening here.
kevinushey commentedon Dec 15, 2022
This sort of feels like an Electron bug; it would be worth testing if this reproduces in the builds of RStudio using the latest version of Electron.
Zweckoptimismus commentedon Feb 8, 2023
@GegznaV , thank you for bringing this up. Have the same issue, and it totally breaks my workflow. (Cannot resist to link to this wonderful xkcd cartoon: https://xkcd.com/1172/)
However, the problem still exists in build 353. Is there any fix in sight already?
5 remaining items
mikebessuille commentedon Feb 13, 2023
Looks like a duplicate of #12470
MintyFreshFarmer commentedon Apr 15, 2023
Is this problem fixed? I'm on 2023.03.0+386 and this problem popped up. The only bypass is this sequence: ctrl -> alt -> press shift (or other buttons, so far just backpsace and s, don't do escape) and let go -> left click and place cursor where you want it.
It's weird but works for me. I found this after some testing for key glitches. At some point in time I was able to use shift+alt to get multi cursor to work in this version, but somehow it disappeared. Very bugged. Hope they fix it, multi cursor is a staple function lol.
douglaswhitaker commentedon Jun 13, 2023
I'm still having this issue with the most recent version of RStudio, but the Shift + Alt suggestion earlier in the thread seems to be working (at least for the first day I've tried it).
RStudio 2023.06.0+421 "Mountain Hydrangea" Release (583b465, 2023-06-05) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.0+421 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36
rjvelasquezm commentedon Jul 13, 2023
Curious if there are any plans to fix this?
Personally, and Im sure others have the issue, it just doesnt make sense to update to the latest RStudios where my workflow will take a hit unless its just never going to happen and Ill just have to accept it and deal with it.
timtmok commentedon Jul 13, 2023
This behaviour comes from Electron: electron/electron#34211
Implementing #8932 might work around the issue as some have reported Electron apps that hide the menu bar will no longer immediately change focus. Short of disabling the
Altbehaviour with some custom handling and logic, this is likely to wait on an Electron change. Any change here must ensure that keyboard navigation can activate menus while still allowingAltto column select text in the editor.Saviouress commentedon Aug 22, 2023
This bug is so annoying that I'm still on RStudio 2022.07.2
GegznaV commentedon Aug 23, 2023
Try using Shift+Alt instead of just Alt. It took a while for me to learn the new habit, but it allows using the current version of RStudio.
RRTogunov commentedon Sep 21, 2023
For those on Windows, another (very Jankey) workaround using Autohotkey is to trigger "right click" and "escape" whenever you press click+ alt
Took me forever to figure out something that works and doesn't interfere with other functions (eg multicursor).
Here is code using AutoHotKey V2
Note: I opted for right-click+escape because Rstudio doesn't always lose focus from console with multi-line selection, in which case sending {alt} would inadvertently shift focus to menu bar and {esc} would cancel the selection.
Also, applicable to duplicate issues:
#12470 (comment)
#12906 (comment)
max-nothacker commentedon Aug 15, 2024
This bug wasn't fixed yet, was it?
Because I am still having issues with a recent version:
RStudio Version: 2024.04.2+764
Release Name: "Chocolate Cosmos"
Release Date: 2024-06-05
Quarto Version: 1.4.555
Commit Hash: e4392fc
Zweckoptimismus commentedon Aug 16, 2024
No, unfortunately not. My workflow has now changed to "release Alt key and press Alt key again" to unfocus the menu and instead return the focus to script window. :-/