diff --git a/library/ui/gestures.factor b/library/ui/gestures.factor index 80e1afec87..1b6829676c 100644 --- a/library/ui/gestures.factor +++ b/library/ui/gestures.factor @@ -69,6 +69,7 @@ SYMBOL: hand-loc SYMBOL: hand-clicked SYMBOL: hand-click-loc +SYMBOL: hand-click# SYMBOL: hand-buttons V{ } clone hand-buttons set-global diff --git a/library/ui/windows/ui.factor b/library/ui/windows/ui.factor index 7f1da11609..29b01e0118 100644 --- a/library/ui/windows/ui.factor +++ b/library/ui/windows/ui.factor @@ -165,14 +165,35 @@ SYMBOL: hWnd : mouse-lparam ( lParam -- seq ) [ lo-word ] keep hi-word 2array ; : mouse-wheel ( lParam -- n ) mouse-lparam [ sgn neg ] map ; +SYMBOL: last-button +SYMBOL: last-time +0 last-button set-global +0 last-time set-global + +: update-click# ( button -- ) + last-button get = [ + global [ hand-click# inc ] bind + ] [ + 1 hand-click# set-global + ] if ; + +: mouse-click ( button -- ) + millis last-time get - GetDoubleClickTime < [ + dup update-click# + ] [ + 1 hand-click# set-global + ] if + last-button set + millis last-time set ; + : mouse-event>gesture ( uMsg -- button ) key-modifiers swap { - { [ dup WM_LBUTTONDOWN = ] [ drop 1 ] } + { [ dup WM_LBUTTONDOWN = ] [ drop 1 dup mouse-click ] } { [ dup WM_LBUTTONUP = ] [ drop 1 ] } - { [ dup WM_MBUTTONDOWN = ] [ drop 2 ] } + { [ dup WM_MBUTTONDOWN = ] [ drop 2 dup mouse-click ] } { [ dup WM_MBUTTONUP = ] [ drop 2 ] } - { [ dup WM_RBUTTONDOWN = ] [ drop 3 ] } + { [ dup WM_RBUTTONDOWN = ] [ drop 3 dup mouse-click ] } { [ dup WM_RBUTTONUP = ] [ drop 3 ] } { [ t ] [ "bad button" throw ] } } cond ; diff --git a/library/windows/user32.factor b/library/windows/user32.factor index 2010b38974..73c645f161 100644 --- a/library/windows/user32.factor +++ b/library/windows/user32.factor @@ -822,7 +822,7 @@ FUNCTION: HDC GetDCEx ( HWND hWnd, HRGN hrgnClip, DWORD flags ) ; ! FUNCTION: GetDlgItemInt ! FUNCTION: GetDlgItemTextA ! FUNCTION: GetDlgItemTextW -! FUNCTION: GetDoubleClickTime +FUNCTION: uint GetDoubleClickTime ( ) ; FUNCTION: HWND GetFocus ( ) ; ! FUNCTION: GetForegroundWindow ! FUNCTION: GetGuiResources