forked from trevordevore/levurehelper-dataview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmac_scroll_wheel.lcb
74 lines (63 loc) · 2.77 KB
/
mac_scroll_wheel.lcb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
library community.livecode.trevordevore.macosscrollwheel
use com.livecode.foreign
use com.livecode.objc
metadata title is "macOS Scroll Wheel"
metadata author is "Trevor DeVore"
metadata version is "1.1.0"
private type NSUInteger is CULong
constant kNSEventTypeScrollWheel is 22
private foreign handler ObjC_NSApplicationSharedApplication() \
returns ObjcId \
binds to "objc:NSApplication.+sharedApplication"
private foreign handler ObjC_NSApplicationCurrentEvent(in pSharedApp as ObjcId) \
returns ObjcId \
binds to "objc:NSApplication.currentEvent"
private foreign handler ObjC_NSEventScrollingDeltaX(in pEvent as ObjcId) \
returns NaturalFloat \
binds to "objc:NSEvent.scrollingDeltaX"
private foreign handler ObjC_NSEventScrollingDeltaY(in pEvent as ObjcId) \
returns NaturalFloat \
binds to "objc:NSEvent.scrollingDeltaY"
private foreign handler ObjC_NSEventDeltaX(in pEvent as ObjcId) \
returns NaturalFloat \
binds to "objc:NSEvent.deltaX"
private foreign handler ObjC_NSEventDeltaY(in pEvent as ObjcId) \
returns NaturalFloat \
binds to "objc:NSEvent.deltaY"
private foreign handler ObjC_NSEventHasPreciseScrollingDeltas(in pEvent as ObjcId) \
returns CBool \
binds to "objc:NSEvent.hasPreciseScrollingDeltas"
private foreign handler ObjC_NSEventType(in pEvent as ObjcId) \
returns NSUInteger \
binds to "objc:NSEvent.type"
/**
Summary: Returns the x/y scroll delta values for the last event.
Parameters:
pRowHeight: Value to use to calculate value if `hasPreciseScrollingDeltas` is false (some mouse scroll wheels).
Returns: List of deltaX,deltaY
*/
public handler macCurrentEventScrollValues(in pRowHeight as Number) returns String
variable nsApp as ObjcObject
variable nsEvent as ObjcObject
variable tPoints as String
variable tDeltaX as Number
variable tDeltaY as Number
variable tEventType as Number
unsafe
put ObjC_NSApplicationSharedApplication() into nsApp
put ObjC_NSApplicationCurrentEvent(nsApp) into nsEvent
if ObjC_NSEventType(nsEvent) is kNSEventTypeScrollWheel then
put ObjC_NSEventScrollingDeltaX(nsEvent) into tDeltaX
put ObjC_NSEventScrollingDeltaY(nsEvent) into tDeltaY
-- When hasPreciseScrollingDeltas is NO, multiply the value returned by this method by the line or row height. Otherwise scroll by the returned amount.
if not ObjC_NSEventHasPreciseScrollingDeltas(nsEvent) then
multiply tDeltaX by pRowHeight
multiply tDeltaY by pRowHeight
end if
end if
end unsafe
put tDeltaX formatted as string & "," & \
tDeltaY formatted as string into tPoints
return tPoints
end handler
end library