Cocoa double/triple clicks; editor now handles this
parent
4e66169ea5
commit
bd41d181e8
|
@ -24,7 +24,6 @@
|
|||
- fix top level window positioning
|
||||
- services do not launch if factor not running
|
||||
- editor:
|
||||
- double/triple click
|
||||
- autoscroll
|
||||
- transpose char/word/line
|
||||
- more efficient multi-line inserts
|
||||
|
|
|
@ -91,11 +91,16 @@ opengl sequences ;
|
|||
: mouse-event>gesture ( event -- modifiers button )
|
||||
dup event-modifiers swap button ;
|
||||
|
||||
: update-click-count ( event -- )
|
||||
-> clickCount 1 max hand-click# set-global ;
|
||||
|
||||
: send-button-down$ ( view event -- )
|
||||
[ update-click-count ] keep
|
||||
[ mouse-event>gesture <button-down> ] 2keep
|
||||
mouse-location rot window send-button-down ;
|
||||
|
||||
: send-button-up$ ( view event -- )
|
||||
[ update-click-count ] keep
|
||||
[ mouse-event>gesture <button-up> ] 2keep
|
||||
mouse-location rot window send-button-up ;
|
||||
|
||||
|
|
|
@ -8,3 +8,21 @@ gadgets ;
|
|||
"editor" get editor-text [ \ = see ] string-out =
|
||||
"editor" get ungraft*
|
||||
] unit-test
|
||||
|
||||
[ "foo bar" ] [
|
||||
<editor> "editor" set
|
||||
"editor" get graft*
|
||||
"foo bar" "editor" get set-editor-text
|
||||
"editor" get T{ one-line-elt } select-elt
|
||||
"editor" get gadget-selection
|
||||
"editor" get ungraft*
|
||||
] unit-test
|
||||
|
||||
[ "baz quux" ] [
|
||||
<editor> "editor" set
|
||||
"editor" get graft*
|
||||
"foo bar\nbaz quux" "editor" get set-editor-text
|
||||
"editor" get T{ one-line-elt } select-elt
|
||||
"editor" get gadget-selection
|
||||
"editor" get ungraft*
|
||||
] unit-test
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
! Copyright (C) 2006 Slava Pestov
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: gadgets-text
|
||||
USING: gadgets kernel models namespaces sequences ;
|
||||
USING: gadgets kernel models namespaces sequences arrays ;
|
||||
|
||||
: editor-extend-selection ( editor -- )
|
||||
dup request-focus
|
||||
dup editor-caret click-loc ;
|
||||
|
||||
: editor-mouse-down ( editor -- )
|
||||
dup editor-extend-selection
|
||||
dup editor-mark click-loc ;
|
||||
|
||||
: editor-mouse-drag ( editor -- )
|
||||
dup editor-caret click-loc ;
|
||||
|
||||
|
@ -70,6 +66,18 @@ USING: gadgets kernel models namespaces sequences ;
|
|||
[ dup T{ word-elt } select-elt ] unless
|
||||
gadget-selection ;
|
||||
|
||||
: position-caret ( editor -- )
|
||||
dup editor-extend-selection
|
||||
dup editor-mark click-loc ;
|
||||
|
||||
: editor-mouse-down ( editor -- )
|
||||
hand-click# get {
|
||||
[ ]
|
||||
[ dup position-caret ]
|
||||
[ dup T{ word-elt } select-elt ]
|
||||
[ dup T{ one-line-elt } select-elt ]
|
||||
} ?nth call drop ;
|
||||
|
||||
editor "editing" {
|
||||
{ "Insert newline" T{ key-down f f "RETURN" } [ "\n" swap user-input ] }
|
||||
{ "Insert newline" T{ key-down f { S+ } "RETURN" } [ "\n" swap user-input ] }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
IN: gadgets-text
|
||||
USING: arrays kernel math sequences strings ;
|
||||
USING: arrays kernel math sequences strings models ;
|
||||
|
||||
GENERIC: prev-elt ( loc document elt -- loc )
|
||||
GENERIC: next-elt ( loc document elt -- loc )
|
||||
|
|
Loading…
Reference in New Issue