Use singletons instead of empty tuples, add undo/redo to editor gadgets
parent
33c955775b
commit
af744e4511
|
@ -197,24 +197,32 @@ CLASS: {
|
||||||
[ nip send-key-up-event ]
|
[ nip send-key-up-event ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ "undo:" "id" { "id" "SEL" "id" }
|
||||||
|
[ nip undo-action send-action$ ]
|
||||||
|
}
|
||||||
|
|
||||||
|
{ "redo:" "id" { "id" "SEL" "id" }
|
||||||
|
[ nip redo-action send-action$ ]
|
||||||
|
}
|
||||||
|
|
||||||
{ "cut:" "id" { "id" "SEL" "id" }
|
{ "cut:" "id" { "id" "SEL" "id" }
|
||||||
[ nip T{ cut-action } send-action$ ]
|
[ nip cut-action send-action$ ]
|
||||||
}
|
}
|
||||||
|
|
||||||
{ "copy:" "id" { "id" "SEL" "id" }
|
{ "copy:" "id" { "id" "SEL" "id" }
|
||||||
[ nip T{ copy-action } send-action$ ]
|
[ nip copy-action send-action$ ]
|
||||||
}
|
}
|
||||||
|
|
||||||
{ "paste:" "id" { "id" "SEL" "id" }
|
{ "paste:" "id" { "id" "SEL" "id" }
|
||||||
[ nip T{ paste-action } send-action$ ]
|
[ nip paste-action send-action$ ]
|
||||||
}
|
}
|
||||||
|
|
||||||
{ "delete:" "id" { "id" "SEL" "id" }
|
{ "delete:" "id" { "id" "SEL" "id" }
|
||||||
[ nip T{ delete-action } send-action$ ]
|
[ nip delete-action send-action$ ]
|
||||||
}
|
}
|
||||||
|
|
||||||
{ "selectAll:" "id" { "id" "SEL" "id" }
|
{ "selectAll:" "id" { "id" "SEL" "id" }
|
||||||
[ nip T{ select-all-action } send-action$ ]
|
[ nip select-all-action send-action$ ]
|
||||||
}
|
}
|
||||||
|
|
||||||
! Multi-touch gestures: this is undocumented.
|
! Multi-touch gestures: this is undocumented.
|
||||||
|
@ -223,8 +231,8 @@ CLASS: {
|
||||||
[
|
[
|
||||||
nip
|
nip
|
||||||
dup -> deltaZ sgn {
|
dup -> deltaZ sgn {
|
||||||
{ 1 [ T{ zoom-in-action } send-action$ ] }
|
{ 1 [ zoom-in-action send-action$ ] }
|
||||||
{ -1 [ T{ zoom-out-action } send-action$ ] }
|
{ -1 [ zoom-out-action send-action$ ] }
|
||||||
{ 0 [ 2drop ] }
|
{ 0 [ 2drop ] }
|
||||||
} case
|
} case
|
||||||
]
|
]
|
||||||
|
@ -234,13 +242,13 @@ CLASS: {
|
||||||
[
|
[
|
||||||
nip
|
nip
|
||||||
dup -> deltaX sgn {
|
dup -> deltaX sgn {
|
||||||
{ 1 [ T{ left-action } send-action$ ] }
|
{ 1 [ left-action send-action$ ] }
|
||||||
{ -1 [ T{ right-action } send-action$ ] }
|
{ -1 [ right-action send-action$ ] }
|
||||||
{ 0
|
{ 0
|
||||||
[
|
[
|
||||||
dup -> deltaY sgn {
|
dup -> deltaY sgn {
|
||||||
{ 1 [ T{ up-action } send-action$ ] }
|
{ 1 [ up-action send-action$ ] }
|
||||||
{ -1 [ T{ down-action } send-action$ ] }
|
{ -1 [ down-action send-action$ ] }
|
||||||
{ 0 [ 2drop ] }
|
{ 0 [ 2drop ] }
|
||||||
} case
|
} case
|
||||||
]
|
]
|
||||||
|
|
|
@ -35,8 +35,8 @@ TUPLE: button < border pressed? selected? quot ;
|
||||||
button H{
|
button H{
|
||||||
{ T{ button-up } [ button-clicked ] }
|
{ T{ button-up } [ button-clicked ] }
|
||||||
{ T{ button-down } [ button-update ] }
|
{ T{ button-down } [ button-update ] }
|
||||||
{ T{ mouse-leave } [ button-update ] }
|
{ mouse-leave [ button-update ] }
|
||||||
{ T{ mouse-enter } [ button-update ] }
|
{ mouse-enter [ button-update ] }
|
||||||
} set-gestures
|
} set-gestures
|
||||||
|
|
||||||
: new-button ( label quot class -- button )
|
: new-button ( label quot class -- button )
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
USING: accessors ui.gadgets.editors tools.test kernel io
|
USING: accessors ui.gadgets.editors tools.test kernel io
|
||||||
io.streams.plain definitions namespaces ui.gadgets
|
io.streams.plain definitions namespaces ui.gadgets
|
||||||
ui.gadgets.grids prettyprint documents ui.gestures tools.test.ui
|
ui.gadgets.grids prettyprint documents ui.gestures tools.test.ui
|
||||||
models ;
|
models documents.elements ;
|
||||||
IN: ui.gadgets.editors.tests
|
IN: ui.gadgets.editors.tests
|
||||||
|
|
||||||
[ "foo bar" ] [
|
[ "foo bar" ] [
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
! Copyright (C) 2006, 2009 Slava Pestov
|
! Copyright (C) 2006, 2009 Slava Pestov
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays documents kernel math models models.filter
|
USING: accessors arrays documents documents.elements kernel math
|
||||||
namespaces locals fry make opengl opengl.gl sequences strings
|
models models.filter namespaces locals fry make opengl opengl.gl
|
||||||
math.vectors sorting colors combinators assocs math.order fry
|
sequences strings math.vectors sorting colors combinators assocs
|
||||||
calendar alarms continuations ui.clipboards ui.commands
|
math.order fry calendar alarms continuations ui.clipboards ui.commands
|
||||||
ui.gadgets ui.gadgets.borders ui.gadgets.buttons
|
ui.gadgets ui.gadgets.borders ui.gadgets.buttons ui.gadgets.labels
|
||||||
ui.gadgets.labels ui.gadgets.scrollers ui.gadgets.theme
|
ui.gadgets.scrollers ui.gadgets.theme ui.gadgets.menus
|
||||||
ui.gadgets.menus ui.gadgets.wrappers ui.render ui.text
|
ui.gadgets.wrappers ui.render ui.text ui.gestures math.geometry.rect
|
||||||
ui.gestures math.geometry.rect splitting unicode.categories ;
|
splitting unicode.categories ;
|
||||||
IN: ui.gadgets.editors
|
IN: ui.gadgets.editors
|
||||||
|
|
||||||
TUPLE: editor < gadget
|
TUPLE: editor < gadget
|
||||||
|
@ -377,7 +377,15 @@ M: editor gadget-text* editor-string % ;
|
||||||
: delete-to-end-of-line ( editor -- )
|
: delete-to-end-of-line ( editor -- )
|
||||||
one-line-elt editor-backspace ;
|
one-line-elt editor-backspace ;
|
||||||
|
|
||||||
editor "general" f {
|
: com-undo ( editor -- )
|
||||||
|
model>> undo ;
|
||||||
|
|
||||||
|
: com-redo ( editor -- )
|
||||||
|
model>> redo ;
|
||||||
|
|
||||||
|
editor "editing" f {
|
||||||
|
{ undo-action com-undo }
|
||||||
|
{ redo-action com-redo }
|
||||||
{ T{ key-down f f "DELETE" } delete-next-character }
|
{ T{ key-down f f "DELETE" } delete-next-character }
|
||||||
{ T{ key-down f { S+ } "DELETE" } delete-next-character }
|
{ T{ key-down f { S+ } "DELETE" } delete-next-character }
|
||||||
{ T{ key-down f f "BACKSPACE" } delete-previous-character }
|
{ T{ key-down f f "BACKSPACE" } delete-previous-character }
|
||||||
|
@ -395,11 +403,11 @@ editor "general" f {
|
||||||
: cut ( editor -- ) clipboard get editor-cut ;
|
: cut ( editor -- ) clipboard get editor-cut ;
|
||||||
|
|
||||||
editor "clipboard" f {
|
editor "clipboard" f {
|
||||||
{ T{ paste-action } paste }
|
{ paste-action paste }
|
||||||
|
{ copy-action com-copy }
|
||||||
|
{ cut-action cut }
|
||||||
{ T{ button-up f f 2 } paste-selection }
|
{ T{ button-up f f 2 } paste-selection }
|
||||||
{ T{ copy-action } com-copy }
|
|
||||||
{ T{ button-up } com-copy-selection }
|
{ T{ button-up } com-copy-selection }
|
||||||
{ T{ cut-action } cut }
|
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
: previous-character ( editor -- )
|
: previous-character ( editor -- )
|
||||||
|
@ -480,10 +488,10 @@ editor "caret-motion" f {
|
||||||
editor "selection" f {
|
editor "selection" f {
|
||||||
{ T{ button-down f { S+ } 1 } extend-selection }
|
{ T{ button-down f { S+ } 1 } extend-selection }
|
||||||
{ T{ drag } drag-selection }
|
{ T{ drag } drag-selection }
|
||||||
{ T{ gain-focus } focus-editor }
|
{ gain-focus focus-editor }
|
||||||
{ T{ lose-focus } unfocus-editor }
|
{ lose-focus unfocus-editor }
|
||||||
{ T{ delete-action } remove-selection }
|
{ delete-action remove-selection }
|
||||||
{ T{ select-all-action } select-all }
|
{ select-all-action select-all }
|
||||||
{ T{ key-down f { C+ } "l" } select-line }
|
{ T{ key-down f { C+ } "l" } select-line }
|
||||||
{ T{ key-down f { S+ } "LEFT" } select-previous-character }
|
{ T{ key-down f { S+ } "LEFT" } select-previous-character }
|
||||||
{ T{ key-down f { S+ } "RIGHT" } select-next-character }
|
{ T{ key-down f { S+ } "RIGHT" } select-next-character }
|
||||||
|
|
|
@ -414,6 +414,6 @@ pane H{
|
||||||
{ T{ button-up f { S+ } 1 } [ end-selection ] }
|
{ T{ button-up f { S+ } 1 } [ end-selection ] }
|
||||||
{ T{ button-up } [ end-selection ] }
|
{ T{ button-up } [ end-selection ] }
|
||||||
{ T{ drag } [ extend-selection ] }
|
{ T{ drag } [ extend-selection ] }
|
||||||
{ T{ copy-action } [ com-copy ] }
|
{ copy-action [ com-copy ] }
|
||||||
{ T{ button-down f f 3 } [ pane-menu ] }
|
{ T{ button-down f f 3 } [ pane-menu ] }
|
||||||
} set-gestures
|
} set-gestures
|
||||||
|
|
|
@ -40,11 +40,11 @@ M: presentation ungraft*
|
||||||
|
|
||||||
presentation H{
|
presentation H{
|
||||||
{ T{ button-down f f 3 } [ show-presentation-menu ] }
|
{ T{ button-down f f 3 } [ show-presentation-menu ] }
|
||||||
{ T{ mouse-leave } [ [ hide-status ] [ button-update ] bi ] }
|
{ mouse-leave [ [ hide-status ] [ button-update ] bi ] }
|
||||||
{ T{ mouse-enter } [ show-mouse-help ] }
|
{ mouse-enter [ show-mouse-help ] }
|
||||||
! Responding to motion too allows nested presentations to
|
! Responding to motion too allows nested presentations to
|
||||||
! display status help properly, when the mouse leaves a
|
! display status help properly, when the mouse leaves a
|
||||||
! nested presentation and is still inside the parent, the
|
! nested presentation and is still inside the parent, the
|
||||||
! parent doesn't receive a mouse-enter
|
! parent doesn't receive a mouse-enter
|
||||||
{ T{ motion } [ show-mouse-help ] }
|
{ motion [ show-mouse-help ] }
|
||||||
} set-gestures
|
} set-gestures
|
||||||
|
|
|
@ -27,7 +27,7 @@ TUPLE: scroller < frame viewport x y follows ;
|
||||||
2bi ;
|
2bi ;
|
||||||
|
|
||||||
scroller H{
|
scroller H{
|
||||||
{ T{ mouse-scroll } [ do-mouse-scroll ] }
|
{ mouse-scroll [ do-mouse-scroll ] }
|
||||||
} set-gestures
|
} set-gestures
|
||||||
|
|
||||||
: <scroller-model> ( -- model )
|
: <scroller-model> ( -- model )
|
||||||
|
|
|
@ -300,14 +300,14 @@ PRIVATE>
|
||||||
] [ drop ] if-mouse-row ;
|
] [ drop ] if-mouse-row ;
|
||||||
|
|
||||||
table H{
|
table H{
|
||||||
{ T{ mouse-enter } [ show-mouse-help ] }
|
{ mouse-enter [ show-mouse-help ] }
|
||||||
{ T{ mouse-leave } [ hide-mouse-help ] }
|
{ mouse-leave [ hide-mouse-help ] }
|
||||||
{ T{ motion } [ show-mouse-help ] }
|
{ motion [ show-mouse-help ] }
|
||||||
{ T{ button-down } [ table-button-down ] }
|
{ T{ button-down } [ table-button-down ] }
|
||||||
{ T{ button-down f f 3 } [ show-table-menu ] }
|
{ T{ button-down f f 3 } [ show-table-menu ] }
|
||||||
{ T{ button-up } [ table-button-up ] }
|
{ T{ button-up } [ table-button-up ] }
|
||||||
{ T{ gain-focus } [ t >>focused? drop ] }
|
{ gain-focus [ t >>focused? drop ] }
|
||||||
{ T{ lose-focus } [ f >>focused? drop ] }
|
{ lose-focus [ f >>focused? drop ] }
|
||||||
{ T{ drag } [ table-button-down ] }
|
{ T{ drag } [ table-button-down ] }
|
||||||
{ T{ key-down f f "RET" } [ row-action ] }
|
{ T{ key-down f f "RET" } [ row-action ] }
|
||||||
{ T{ key-down f f "UP" } [ prev-row ] }
|
{ T{ key-down f f "UP" } [ prev-row ] }
|
||||||
|
|
|
@ -92,10 +92,12 @@ ui-error-hook global [ [ rethrow ] or ] change-at
|
||||||
] [ drop ] if ;
|
] [ drop ] if ;
|
||||||
|
|
||||||
world H{
|
world H{
|
||||||
{ T{ key-down f { C+ } "x" } [ T{ cut-action } send-action ] }
|
{ T{ key-down f { C+ } "z" } [ undo-action send-action ] }
|
||||||
{ T{ key-down f { C+ } "c" } [ T{ copy-action } send-action ] }
|
{ T{ key-down f { C+ } "Z" } [ redo-action send-action ] }
|
||||||
{ T{ key-down f { C+ } "v" } [ T{ paste-action } send-action ] }
|
{ T{ key-down f { C+ } "x" } [ cut-action send-action ] }
|
||||||
{ T{ key-down f { C+ } "a" } [ T{ select-all-action } send-action ] }
|
{ T{ key-down f { C+ } "c" } [ copy-action send-action ] }
|
||||||
|
{ T{ key-down f { C+ } "v" } [ paste-action send-action ] }
|
||||||
|
{ T{ key-down f { C+ } "a" } [ select-all-action send-action ] }
|
||||||
{ T{ button-down f { C+ } 1 } [ drop T{ button-down f f 3 } button-gesture ] }
|
{ T{ button-down f { C+ } 1 } [ drop T{ button-down f f 3 } button-gesture ] }
|
||||||
{ T{ button-down f { A+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
|
{ T{ button-down f { A+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
|
||||||
{ T{ button-down f { M+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
|
{ T{ button-down f { M+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
|
||||||
|
|
|
@ -23,7 +23,7 @@ HELP: propagate-gesture
|
||||||
|
|
||||||
HELP: motion
|
HELP: motion
|
||||||
{ $class-description "Mouse motion gesture." }
|
{ $class-description "Mouse motion gesture." }
|
||||||
{ $examples { $code "T{ motion }" } } ;
|
{ $examples { $code "motion" } } ;
|
||||||
|
|
||||||
HELP: drag
|
HELP: drag
|
||||||
{ $class-description "Mouse drag gesture. The " { $snippet "#" } " slot is either set to a mouse button number, or " { $link f } " indicating no specific button is expected." } ;
|
{ $class-description "Mouse drag gesture. The " { $snippet "#" } " slot is either set to a mouse button number, or " { $link f } " indicating no specific button is expected." } ;
|
||||||
|
@ -48,43 +48,43 @@ HELP: button-down
|
||||||
|
|
||||||
HELP: mouse-scroll
|
HELP: mouse-scroll
|
||||||
{ $class-description "Scroll wheel motion gesture. When this gesture is sent, the " { $link scroll-direction } " global variable is set to a direction vector." }
|
{ $class-description "Scroll wheel motion gesture. When this gesture is sent, the " { $link scroll-direction } " global variable is set to a direction vector." }
|
||||||
{ $examples { $code "T{ mouse-scroll }" } } ;
|
{ $examples { $code "mouse-scroll" } } ;
|
||||||
|
|
||||||
HELP: mouse-enter
|
HELP: mouse-enter
|
||||||
{ $class-description "Gesture sent when the mouse enters the bounds of a gadget." }
|
{ $class-description "Gesture sent when the mouse enters the bounds of a gadget." }
|
||||||
{ $examples { $code "T{ mouse-enter }" } } ;
|
{ $examples { $code "mouse-enter" } } ;
|
||||||
|
|
||||||
HELP: mouse-leave
|
HELP: mouse-leave
|
||||||
{ $class-description "Gesture sent when the mouse leaves the bounds of a gadget." }
|
{ $class-description "Gesture sent when the mouse leaves the bounds of a gadget." }
|
||||||
{ $examples { $code "T{ mouse-leave }" } } ;
|
{ $examples { $code "mouse-leave" } } ;
|
||||||
|
|
||||||
HELP: gain-focus
|
HELP: gain-focus
|
||||||
{ $class-description "Gesture sent when a gadget gains keyboard focus." }
|
{ $class-description "Gesture sent when a gadget gains keyboard focus." }
|
||||||
{ $examples { $code "T{ gain-focus }" } } ;
|
{ $examples { $code "gain-focus" } } ;
|
||||||
|
|
||||||
HELP: lose-focus
|
HELP: lose-focus
|
||||||
{ $class-description "Gesture sent when a gadget loses keyboard focus." }
|
{ $class-description "Gesture sent when a gadget loses keyboard focus." }
|
||||||
{ $examples { $code "T{ lose-focus }" } } ;
|
{ $examples { $code "lose-focus" } } ;
|
||||||
|
|
||||||
HELP: cut-action
|
HELP: cut-action
|
||||||
{ $class-description "Gesture sent when the " { $emphasis "cut" } " standard window system action is invoked." }
|
{ $class-description "Gesture sent when the " { $emphasis "cut" } " standard window system action is invoked." }
|
||||||
{ $examples { $code "T{ cut-action }" } } ;
|
{ $examples { $code "cut-action" } } ;
|
||||||
|
|
||||||
HELP: copy-action
|
HELP: copy-action
|
||||||
{ $class-description "Gesture sent when the " { $emphasis "copy" } " standard window system action is invoked." }
|
{ $class-description "Gesture sent when the " { $emphasis "copy" } " standard window system action is invoked." }
|
||||||
{ $examples { $code "T{ copy-action }" } } ;
|
{ $examples { $code "copy-action" } } ;
|
||||||
|
|
||||||
HELP: paste-action
|
HELP: paste-action
|
||||||
{ $class-description "Gesture sent when the " { $emphasis "paste" } " standard window system action is invoked." }
|
{ $class-description "Gesture sent when the " { $emphasis "paste" } " standard window system action is invoked." }
|
||||||
{ $examples { $code "T{ paste-action }" } } ;
|
{ $examples { $code "paste-action" } } ;
|
||||||
|
|
||||||
HELP: delete-action
|
HELP: delete-action
|
||||||
{ $class-description "Gesture sent when the " { $emphasis "delete" } " standard window system action is invoked." }
|
{ $class-description "Gesture sent when the " { $emphasis "delete" } " standard window system action is invoked." }
|
||||||
{ $examples { $code "T{ delete-action }" } } ;
|
{ $examples { $code "delete-action" } } ;
|
||||||
|
|
||||||
HELP: select-all-action
|
HELP: select-all-action
|
||||||
{ $class-description "Gesture sent when the " { $emphasis "select all" } " standard window system action is invoked." }
|
{ $class-description "Gesture sent when the " { $emphasis "select all" } " standard window system action is invoked." }
|
||||||
{ $examples { $code "T{ select-all-action }" } } ;
|
{ $examples { $code "select-all-action" } } ;
|
||||||
|
|
||||||
HELP: C+
|
HELP: C+
|
||||||
{ $description "Control key modifier." } ;
|
{ $description "Control key modifier." } ;
|
||||||
|
@ -359,10 +359,12 @@ ARTICLE: "action-gestures" "Action gestures"
|
||||||
"The following keyboard gestures, if not handled directly, send action gestures:"
|
"The following keyboard gestures, if not handled directly, send action gestures:"
|
||||||
{ $table
|
{ $table
|
||||||
{ { $strong "Keyboard gesture" } { $strong "Action gesture" } }
|
{ { $strong "Keyboard gesture" } { $strong "Action gesture" } }
|
||||||
{ { $snippet "T{ key-down f { C+ } \"x\" }" } { $snippet "T{ cut-action }" } }
|
{ { $snippet "T{ key-down f { C+ } \"z\" }" } { $snippet "undo-action" } }
|
||||||
{ { $snippet "T{ key-down f { C+ } \"c\" }" } { $snippet "T{ copy-action }" } }
|
{ { $snippet "T{ key-down f { C+ } \"Z\" }" } { $snippet "redo-action" } }
|
||||||
{ { $snippet "T{ key-down f { C+ } \"v\" }" } { $snippet "T{ paste-action }" } }
|
{ { $snippet "T{ key-down f { C+ } \"x\" }" } { $snippet "cut-action" } }
|
||||||
{ { $snippet "T{ key-down f { C+ } \"a\" }" } { $snippet "T{ select-all }" } }
|
{ { $snippet "T{ key-down f { C+ } \"c\" }" } { $snippet "copy-action" } }
|
||||||
|
{ { $snippet "T{ key-down f { C+ } \"v\" }" } { $snippet "paste-action" } }
|
||||||
|
{ { $snippet "T{ key-down f { C+ } \"a\" }" } { $snippet "select-all-action" } }
|
||||||
}
|
}
|
||||||
"Action gestures should be used in place of the above keyboard gestures if possible. For example, on Mac OS X, the standard " { $strong "Edit" } " menu items send action gestures." ;
|
"Action gestures should be used in place of the above keyboard gestures if possible. For example, on Mac OS X, the standard " { $strong "Edit" } " menu items send action gestures." ;
|
||||||
|
|
||||||
|
|
|
@ -66,30 +66,23 @@ M: user-input send-queued-gesture
|
||||||
'[ _ \ user-input queue-gesture ] unless-empty ;
|
'[ _ \ user-input queue-gesture ] unless-empty ;
|
||||||
|
|
||||||
! Gesture objects
|
! Gesture objects
|
||||||
TUPLE: motion ; C: <motion> motion
|
|
||||||
TUPLE: drag # ; C: <drag> drag
|
TUPLE: drag # ; C: <drag> drag
|
||||||
TUPLE: button-up mods # ; C: <button-up> button-up
|
TUPLE: button-up mods # ; C: <button-up> button-up
|
||||||
TUPLE: button-down mods # ; C: <button-down> button-down
|
TUPLE: button-down mods # ; C: <button-down> button-down
|
||||||
TUPLE: mouse-scroll ; C: <mouse-scroll> mouse-scroll
|
|
||||||
TUPLE: mouse-enter ; C: <mouse-enter> mouse-enter
|
SYMBOLS:
|
||||||
TUPLE: mouse-leave ; C: <mouse-leave> mouse-leave
|
motion
|
||||||
TUPLE: lose-focus ; C: <lose-focus> lose-focus
|
mouse-scroll
|
||||||
TUPLE: gain-focus ; C: <gain-focus> gain-focus
|
mouse-enter mouse-leave
|
||||||
|
lose-focus gain-focus ;
|
||||||
|
|
||||||
! Higher-level actions
|
! Higher-level actions
|
||||||
TUPLE: cut-action ; C: <cut-action> cut-action
|
SYMBOLS:
|
||||||
TUPLE: copy-action ; C: <copy-action> copy-action
|
undo-action redo-action
|
||||||
TUPLE: paste-action ; C: <paste-action> paste-action
|
cut-action copy-action paste-action
|
||||||
TUPLE: delete-action ; C: <delete-action> delete-action
|
delete-action select-all-action
|
||||||
TUPLE: select-all-action ; C: <select-all-action> select-all-action
|
left-action right-action up-action down-action
|
||||||
|
zoom-in-action zoom-out-action ;
|
||||||
TUPLE: left-action ; C: <left-action> left-action
|
|
||||||
TUPLE: right-action ; C: <right-action> right-action
|
|
||||||
TUPLE: up-action ; C: <up-action> up-action
|
|
||||||
TUPLE: down-action ; C: <down-action> down-action
|
|
||||||
|
|
||||||
TUPLE: zoom-in-action ; C: <zoom-in-action> zoom-in-action
|
|
||||||
TUPLE: zoom-out-action ; C: <zoom-out-action> zoom-out-action
|
|
||||||
|
|
||||||
! Modifiers
|
! Modifiers
|
||||||
SYMBOLS: C+ A+ M+ S+ ;
|
SYMBOLS: C+ A+ M+ S+ ;
|
||||||
|
@ -165,15 +158,15 @@ SYMBOL: drag-timer
|
||||||
|
|
||||||
: fire-motion ( -- )
|
: fire-motion ( -- )
|
||||||
hand-buttons get-global empty? [
|
hand-buttons get-global empty? [
|
||||||
T{ motion } hand-gadget get-global propagate-gesture
|
motion hand-gadget get-global propagate-gesture
|
||||||
] [
|
] [
|
||||||
drag-gesture
|
drag-gesture
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: hand-gestures ( new old -- )
|
: hand-gestures ( new old -- )
|
||||||
drop-prefix <reversed>
|
drop-prefix <reversed>
|
||||||
T{ mouse-leave } swap each-gesture
|
mouse-leave swap each-gesture
|
||||||
T{ mouse-enter } swap each-gesture ;
|
mouse-enter swap each-gesture ;
|
||||||
|
|
||||||
: forget-rollover ( -- )
|
: forget-rollover ( -- )
|
||||||
f hand-world set-global
|
f hand-world set-global
|
||||||
|
@ -182,10 +175,10 @@ SYMBOL: drag-timer
|
||||||
parents hand-gestures ;
|
parents hand-gestures ;
|
||||||
|
|
||||||
: send-lose-focus ( gadget -- )
|
: send-lose-focus ( gadget -- )
|
||||||
T{ lose-focus } swap send-gesture ;
|
lose-focus swap send-gesture ;
|
||||||
|
|
||||||
: send-gain-focus ( gadget -- )
|
: send-gain-focus ( gadget -- )
|
||||||
T{ gain-focus } swap send-gesture ;
|
gain-focus swap send-gesture ;
|
||||||
|
|
||||||
: focus-child ( child gadget ? -- )
|
: focus-child ( child gadget ? -- )
|
||||||
[
|
[
|
||||||
|
@ -274,7 +267,7 @@ SYMBOL: drag-timer
|
||||||
: send-wheel ( direction loc world -- )
|
: send-wheel ( direction loc world -- )
|
||||||
move-hand
|
move-hand
|
||||||
scroll-direction set-global
|
scroll-direction set-global
|
||||||
T{ mouse-scroll } hand-gadget get-global propagate-gesture ;
|
mouse-scroll hand-gadget get-global propagate-gesture ;
|
||||||
|
|
||||||
: send-action ( world gesture -- )
|
: send-action ( world gesture -- )
|
||||||
swap world-focus propagate-gesture ;
|
swap world-focus propagate-gesture ;
|
||||||
|
|
|
@ -116,8 +116,8 @@ browser-gadget "navigation" "Commands for navigating in the article hierarchy" {
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
browser-gadget "multi-touch" f {
|
browser-gadget "multi-touch" f {
|
||||||
{ T{ left-action } com-back }
|
{ left-action com-back }
|
||||||
{ T{ right-action } com-forward }
|
{ right-action com-forward }
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
browser-gadget "scrolling"
|
browser-gadget "scrolling"
|
||||||
|
|
|
@ -109,7 +109,7 @@ inspector-gadget "toolbar" f {
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
inspector-gadget "multi-touch" f {
|
inspector-gadget "multi-touch" f {
|
||||||
{ T{ up-action } com-refresh }
|
{ up-action com-refresh }
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
: inspector ( obj -- )
|
: inspector ( obj -- )
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs calendar colors documents fry kernel
|
USING: accessors arrays assocs calendar colors documents
|
||||||
words sets splitting math math.vectors models.delay models.filter
|
documents.elements fry kernel words sets splitting math math.vectors
|
||||||
combinators.short-circuit parser present sequences tools.completion
|
models.delay models.filter combinators.short-circuit parser present
|
||||||
generic generic.standard.engines.tuple
|
sequences tools.completion generic generic.standard.engines.tuple
|
||||||
ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.glass
|
ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.glass
|
||||||
ui.gadgets.scrollers ui.gadgets.tables ui.gadgets.theme
|
ui.gadgets.scrollers ui.gadgets.tables ui.gadgets.theme
|
||||||
ui.gadgets.worlds ui.gadgets.wrappers ui.gestures
|
ui.gadgets.worlds ui.gadgets.wrappers ui.gestures ui.render
|
||||||
ui.render ui.tools.listener.history ;
|
ui.tools.listener.history ;
|
||||||
IN: ui.tools.listener.completion
|
IN: ui.tools.listener.completion
|
||||||
|
|
||||||
: complete-IN:/USE:? ( tokens -- ? )
|
: complete-IN:/USE:? ( tokens -- ? )
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: accessors arrays assocs calendar combinators
|
USING: accessors arrays assocs calendar combinators
|
||||||
combinators.short-circuit compiler.units concurrency.flags
|
combinators.short-circuit compiler.units concurrency.flags
|
||||||
concurrency.mailboxes continuations destructors documents
|
concurrency.mailboxes continuations destructors documents
|
||||||
fry hashtables help help.markup io
|
documents.elements fry hashtables help help.markup io
|
||||||
io.styles kernel lexer listener math models models.delay models.filter
|
io.styles kernel lexer listener math models models.delay models.filter
|
||||||
namespaces parser prettyprint quotations sequences strings threads
|
namespaces parser prettyprint quotations sequences strings threads
|
||||||
tools.vocabs ui ui.commands ui.gadgets ui.gadgets.buttons
|
tools.vocabs ui ui.commands ui.gadgets ui.gadgets.buttons
|
||||||
|
@ -406,7 +406,7 @@ listener-gadget "scrolling"
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
listener-gadget "multi-touch" f {
|
listener-gadget "multi-touch" f {
|
||||||
{ T{ up-action } refresh-all }
|
{ up-action refresh-all }
|
||||||
} define-command-map
|
} define-command-map
|
||||||
|
|
||||||
listener-gadget "other" f {
|
listener-gadget "other" f {
|
||||||
|
|
|
@ -35,8 +35,8 @@ SYMBOL: windows
|
||||||
|
|
||||||
: focus-gestures ( new old -- )
|
: focus-gestures ( new old -- )
|
||||||
drop-prefix <reversed>
|
drop-prefix <reversed>
|
||||||
T{ lose-focus } swap each-gesture
|
lose-focus swap each-gesture
|
||||||
T{ gain-focus } swap each-gesture ;
|
gain-focus swap each-gesture ;
|
||||||
|
|
||||||
: focus-world ( world -- )
|
: focus-world ( world -- )
|
||||||
t >>focused?
|
t >>focused?
|
||||||
|
|
Loading…
Reference in New Issue