Clean up double click handling -- its done in the cross-platform part of the UI now

slava 2006-10-21 06:10:10 +00:00
parent f0bfc94261
commit be94f42030
4 changed files with 30 additions and 34 deletions

View File

@ -5,7 +5,6 @@
[ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 [ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113
] ]
- prettier printing of hashtable literals, alists, cond, ... - prettier printing of hashtable literals, alists, cond, ...
- x11 double click
- menu should stay up if mouse button released - menu should stay up if mouse button released
- roundoff is still not quite right with tracks - roundoff is still not quite right with tracks
- fix compiled gc check - fix compiled gc check

View File

@ -91,16 +91,11 @@ opengl sequences ;
: mouse-event>gesture ( event -- modifiers button ) : mouse-event>gesture ( event -- modifiers button )
dup event-modifiers swap button ; dup event-modifiers swap button ;
: update-click-count ( event -- )
-> clickCount 1 max hand-click# set-global ;
: send-button-down$ ( view event -- ) : send-button-down$ ( view event -- )
[ update-click-count ] keep
[ mouse-event>gesture <button-down> ] 2keep [ mouse-event>gesture <button-down> ] 2keep
mouse-location rot window send-button-down ; mouse-location rot window send-button-down ;
: send-button-up$ ( view event -- ) : send-button-up$ ( view event -- )
[ update-click-count ] keep
[ mouse-event>gesture <button-up> ] 2keep [ mouse-event>gesture <button-up> ] 2keep
mouse-location rot window send-button-up ; mouse-location rot window send-button-up ;

View File

@ -81,6 +81,9 @@ V{ } clone hand-buttons set-global
SYMBOL: scroll-direction SYMBOL: scroll-direction
{ 0 0 } scroll-direction set-global { 0 0 } scroll-direction set-global
SYMBOL: double-click-timeout
100 double-click-timeout set-global
: button-gesture ( gesture -- ) : button-gesture ( gesture -- )
hand-clicked get-global 2dup handle-gesture [ hand-clicked get-global 2dup handle-gesture [
>r generalize-gesture r> handle-gesture drop >r generalize-gesture r> handle-gesture drop
@ -150,31 +153,30 @@ SYMBOL: scroll-direction
: hand-click-rel ( gadget -- loc ) : hand-click-rel ( gadget -- loc )
hand-click-loc get-global relative-loc ; hand-click-loc get-global relative-loc ;
: update-click# ( button -- ) : multi-click? ( button -- ? )
hand-last-button get = [ millis hand-last-time get - double-click-timeout get <=
global [ hand-click# inc ] bind swap hand-last-button get = and ;
] [
1 hand-click# set-global
] if ;
: button-down ( button timeout -- )
millis hand-last-time get - rot < [
dup update-click#
] [
1 hand-click# set-global
] if
hand-last-button set-global
millis hand-last-time set-global ;
: update-click# ( button -- )
global [
multi-click? [
hand-click# inc
] [
1 hand-click# set
] if
] bind ;
: update-clicked ( button -- )
hand-last-button set-global
hand-gadget get-global hand-clicked set-global
hand-loc get-global hand-click-loc set-global
millis hand-last-time set-global ;
: under-hand ( -- seq ) : under-hand ( -- seq )
#! A sequence whose first element is the world and last is #! A sequence whose first element is the world and last is
#! the current gadget, with all parents in between. #! the current gadget, with all parents in between.
hand-gadget get-global parents <reversed> ; hand-gadget get-global parents <reversed> ;
: update-clicked ( -- )
hand-gadget get-global hand-clicked set-global
hand-loc get-global hand-click-loc set-global ;
: move-hand ( loc world -- ) : move-hand ( loc world -- )
dup hand-world set-global dup hand-world set-global
under-hand >r over hand-loc set-global under-hand >r over hand-loc set-global
@ -184,8 +186,10 @@ SYMBOL: scroll-direction
: send-button-down ( gesture loc world -- ) : send-button-down ( gesture loc world -- )
move-hand move-hand
update-clicked dup button-down-#
dup button-down-# hand-buttons get-global push dup update-click#
dup update-clicked
hand-buttons get-global push
button-gesture ; button-gesture ;
: send-button-up ( gesture loc world -- ) : send-button-up ( gesture loc world -- )

View File

@ -165,17 +165,14 @@ SYMBOL: hWnd
: mouse-lparam ( lParam -- seq ) [ lo-word ] keep hi-word 2array ; : mouse-lparam ( lParam -- seq ) [ lo-word ] keep hi-word 2array ;
: mouse-wheel ( lParam -- n ) mouse-lparam [ sgn neg ] map ; : mouse-wheel ( lParam -- n ) mouse-lparam [ sgn neg ] map ;
: win32-button-down ( button -- )
GetDoubleClickTime dup button-down <button-down> ;
: mouse-event>gesture ( uMsg -- button ) : mouse-event>gesture ( uMsg -- button )
key-modifiers swap key-modifiers swap
{ {
{ [ dup WM_LBUTTONDOWN = ] [ drop 1 win32-button-down ] } { [ dup WM_LBUTTONDOWN = ] [ drop 1 <button-down> ] }
{ [ dup WM_LBUTTONUP = ] [ drop 1 <button-up> ] } { [ dup WM_LBUTTONUP = ] [ drop 1 <button-up> ] }
{ [ dup WM_MBUTTONDOWN = ] [ drop 2 win32-button-down ] } { [ dup WM_MBUTTONDOWN = ] [ drop 2 <button-down> ] }
{ [ dup WM_MBUTTONUP = ] [ drop 2 <button-up> ] } { [ dup WM_MBUTTONUP = ] [ drop 2 <button-up> ] }
{ [ dup WM_RBUTTONDOWN = ] [ drop 3 win32-button-down ] } { [ dup WM_RBUTTONDOWN = ] [ drop 3 <button-down> ] }
{ [ dup WM_RBUTTONUP = ] [ drop 3 <button-up> ] } { [ dup WM_RBUTTONUP = ] [ drop 3 <button-up> ] }
{ [ t ] [ "bad button" throw ] } { [ t ] [ "bad button" throw ] }
} cond ; } cond ;
@ -306,7 +303,8 @@ SYMBOL: hWnd
"MSG" <c-object> msg-obj set "MSG" <c-object> msg-obj set
random-class-name class-name set random-class-name class-name set
class-name get <malloc-string> ui-wndproc class-name get <malloc-string> ui-wndproc
register-wndclassex win32-error=0 ; register-wndclassex win32-error=0
GetDoubleClickTime double-click-timeout set-global ;
: cleanup-win32-ui ( -- ) : cleanup-win32-ui ( -- )
class-name get <malloc-string> f UnregisterClass drop ; class-name get <malloc-string> f UnregisterClass drop ;