Skip to content

Alt + select with mouse: editor looses the focus #12310

Open

Description

@GegznaV

System details

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

  1. Open a file in RStudio's Editor that has several rows of text.
  2. Select several rows of text while pressing Alt
  3. 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:
    image

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.

Activity

  1. added
    new
    on Nov 9, 2022
  2. ronblum commented on Nov 9, 2022

    @ronblum
    Contributor

    @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.

  3. added
    info needed
    and removed
    new
    on Nov 9, 2022
  4. GegznaV commented on Nov 9, 2022

    @GegznaV
    Author

    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:

    RS-alt-isue

    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?

  5. GegznaV commented on Nov 9, 2022

    @GegznaV
    Author

    @ronblum, can you reproduce the Alt(hold) → Select → Alt(release) → Delete → Nothing happens sequence 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?

  6. rjvelasquezm commented on Nov 9, 2022

    @rjvelasquezm

    FWIW I see this same behavior (described here #12231 (comment)) when testing the electron build.

  7. added and removed
    info needed
    on Nov 30, 2022
  8. GegznaV commented on Dec 14, 2022

    @GegznaV
    Author

    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?
    RS-alt-new-behavior

    @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).

  9. kevinushey commented on Dec 15, 2022

    @kevinushey
    Collaborator

    Just to confirm, with this sequence of actions: "press and holt Alt, click the mouse to make a multi-cursor selection; release Alt"

    • On older builds of RStudio, focus is not sent to the main menu bar;
    • On new (Electron) builds of RStudio, focus is sent to the main menu bar.

    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.

  10. kevinushey commented on Dec 15, 2022

    @kevinushey
    Collaborator

    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.

  11. Zweckoptimismus commented on Feb 8, 2023

    @Zweckoptimismus

    @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?

  12. 5 remaining items

  13. mikebessuille commented on Feb 13, 2023

    @mikebessuille
    Contributor

    Looks like a duplicate of #12470

  14. added this to the Backlog-2 milestone on Feb 13, 2023
  15. MintyFreshFarmer commented on Apr 15, 2023

    @MintyFreshFarmer

    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.

  16. douglaswhitaker commented on Jun 13, 2023

    @douglaswhitaker

    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

  17. rjvelasquezm commented on Jul 13, 2023

    @rjvelasquezm

    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.

  18. timtmok commented on Jul 13, 2023

    @timtmok
    Contributor

    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 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.

  19. Saviouress commented on Aug 22, 2023

    @Saviouress

    This bug is so annoying that I'm still on RStudio 2022.07.2

  20. GegznaV commented on Aug 23, 2023

    @GegznaV
    Author

    This bug is so annoying that I'm still on RStudio 2022.07.2

    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.

  21. RRTogunov commented on Sep 21, 2023

    @RRTogunov

    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.

    Also, applicable to duplicate issues:
    #12470 (comment)
    #12906 (comment)

  22. modified the milestones: Backlog-2, Later on Oct 5, 2023
  23. max-nothacker commented on Aug 15, 2024

    @max-nothacker

    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

  24. Zweckoptimismus commented on Aug 16, 2024

    @Zweckoptimismus

    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. :-/

  25. modified the milestones: Later, Backlog on Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions