【问题标题】:Middle-click scrolling in VS CodeVS Code 中的鼠标中键滚动
【发布时间】:2015-11-11 07:05:25
【问题描述】:

我一直在使用 VS Code 来构建我的投资组合网站,而且我实际上发现它比 Visual Studio 高效得多,我的意思是,一旦我完成了 vNext 样板文件的所有设置。但我需要最近似乎每个人都从我们这里拿走的中间点击滚动功能。

我在另一个 SO 回答中读到他们对他们的插件 api 不满意,所以他们还没有发布它,但是有任何快捷方式、选项或隐藏的 事物 可以让我启用中键滚动?或者是否有一种启用插件支持的秘密方法,以便我可以自己编写或下载插件?

【问题讨论】:

    标签: visual-studio-code


    【解决方案1】:

    实际上没有办法启用中键滚动。 扩展 API 即将开放供公众使用。只需给他们一点时间来整理所有内容。

    【讨论】:

    • 好的,我暂时接受。谢谢@Wosi。我真的希望他们增加对它的支持。
    • 已经5年了,有什么实际的解决方案吗?厌倦了使用滚动条手动水平滚动。
    【解决方案2】:

    根据this open GitHub issue thread in vscode repo,截至 2021 年 9 月,此功能未实现错误尚未修复。但是,有this AutoHotKey workaround.。为了答案的完整性,这里是源代码,由原作者在GNU General Public License v3.0下授权:

    ; autohotkey script to enable middle mouse button scrolling in VS Code
    ; with the cursor in a text area, hold down the middle mouse button to scroll
    ; outside of text areas, middle mouse is unaffected
    
    #IfWinActive ahk_exe Code.exe ; script is only active in VS Code
        MButton:: ; on middle mouse button click, do the following
            ; check if the cursor is in a text area
            ; if no, send a regular middle click
            ; if yes, scroll
            if (A_Cursor != "IBeam") {
                send {MButton}
            } else {
                scroll := true ; activate scroll
                noScrollZone := 10 ; no scrolling until the mouse moves at least this far
                MouseGetPos, xinit , yinit ; initial position of cursor when middle mouse button is clicked
                while scroll { ; loop until middle mouse button is released
                    ToolTip, SCROLLING ; visual indication that scroll is active
                    MouseGetPos, x , y ; current position of cursor
                    ; check the four cases
                    if (y < yinit - noScrollZone) ; up
                        send, {WheelUp 1}
                    if (y > yinit + noScrollZone) ; down
                        send, {WheelDown 1}
                    if (x < xinit - noScrollZone) ; left
                        send, {WheelLeft 1}
                    if (x > xinit + noScrollZone) ; right
                        send, {WheelRight 1}
                    ; make speed of scroll react to cursor position
                    dist := Round( Sqrt( ( x - xinit )**2 + ( y - yinit )**2 ) ) ; cursor's distance from initial position
                    sleepTime := Max( 300 - dist, 0 ) ; a lower sleeptime gives a faster scroll
                    ; sleepTime:= 100 ; uncomment this line to get a constant scroll speed
                    sleep sleepTime ; loop pauses for this length of time
                }
            }
        return
    #IfWinActive
    
    #IfWinActive ahk_exe Code.exe ; script is only active in VS Code
        MButton Up:: ; on middle mouse button release, do the following
            scroll := false ; cancel scroll
            ToolTip ; cancel tooltip
        return
    #IfWinActive
    
    

    但是,这没有平滑滚动。滚动的那种......跳跃。但这是我们目前拥有的最好的。

    【讨论】:

      猜你喜欢
      • 2022-10-04
      • 2023-03-09
      • 2017-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 1970-01-01
      • 2022-07-05
      相关资源
      最近更新 更多