Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Double click drag should select one additional word at a time #288

Open
aleichtm opened this issue Feb 1, 2023 · 2 comments

Comments

@aleichtm
Copy link

aleichtm commented Feb 1, 2023

Problem Situation:

Currently if you double click on text, hold the second click, and drag, it stays with just the word selected and does not expand the selection. This is a problem because it is different than muscle memory from other programs.

Suggestion:

Implement this behavior so that if you double click and hold the second click and drag, it selects one additional token at a time, as is done on other editors and on web browsers. This is a useful feature because it requires less precision in where you place your mouse.

@rfindler rfindler transferred this issue from racket/drracket Feb 15, 2023
@rfindler
Copy link
Member

This would be a nice feature to have. I believe the relevant code is here.

@aleichtm
Copy link
Author

aleichtm commented Feb 15, 2023

Looks to me like it's specifically in https://github.com/racket/gui/tree/master/gui-lib/mred/private/wxme/pasteboard.rkt

(let ([snip (find-snip x y)])
  (if dragable?
      (begin
        (if snip
            (let ([loc (snip->loc snip)])
              (set! orig-x (loc-x loc))
              (set! orig-y (loc-y loc))
              (set! orig-w (loc-w loc))
              (set! orig-h (loc-h loc))
              (if (not (loc-selected? loc))
                  (begin
                    (unless (send event get-shift-down)
                      (no-selected))
                    (set-caret-owner #f)
                    (add-selected snip)
                    (init-dragging event))
                  (let ([interval (abs (- (send event get-time-stamp)
                                          last-time))])
                    (if (and (send event button-down?)
                              (interval . < . (if s-keymap
                                                  (send s-keymap get-double-click-interval)
                                                  (get-double-click-threshold))))
                        (on-double-click snip event)
                        (let-boxes ([dx sizedxm]
                                    [dy sizedym]
                                    [f? #f])
                            (set-box! f? (find-dot loc x y dx dy))
                          (set! sizedxm dx)
                          (set! sizedym dy)
                          (when f?
                            (set! resizing snip))
                          (init-dragging event)))))
              (when (send event button-down?)
                (set! last-time (send event get-time-stamp))))
            (begin
              (unless (send event get-shift-down)
                (no-selected))
              (set-caret-owner #f)
              (when can-rubberband?
                (set! rubberband? #t))))
        (set! start-x x)
        (set! last-x x)
        (set! start-y y)
        (set! last-y y))
      ;; not dragable:
      (set-caret-owner snip)))
(def/public (on-double-click [snip% snip] [mouse-event% evt])
    (when (has-flag? (snip->flags snip) HANDLES-EVENTS)
      (no-selected)
      (set-caret-owner snip)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants