Last active
December 18, 2018 00:15
-
-
Save rgchris/4a8c3691b730899fb674b9e17d5f409e to your computer and use it in GitHub Desktop.
Sample handler for Scroll Events in Rebol 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebol [ | |
Title: "Detect Scroller" | |
Date: 17-Dec-2018 | |
Author: "Christopher Ross-Gill" | |
] | |
scroll-handler: make object! [ | |
; SCROLL-* events use OFFSET to determine the direction and amount of | |
; scrolling to be considered, therefore to ascertain the offset, one needs | |
; to track the position of the pointer. | |
mouse-offset: 0x0 | |
; As we walk through faces, we need to track the offset of each subface | |
; relative to the parent window face (for which the MOUSE-OFFSET is bound). | |
face-offset: 0x0 | |
step-through: func [face event /window][ | |
face-offset: either window [0x0][face-offset + face/offset] | |
either all [ | |
within? mouse-offset face-offset face/size | |
object? face/feel | |
in face/feel 'scroller | |
][ | |
face/feel/scroller face event | |
throw none ; we found our target, we're done. | |
][ | |
switch type?/word get in face 'pane [ | |
object! [step-through face/pane event] | |
block! [ ; most prominent faces first | |
foreach kid reverse copy face/pane [ | |
step-through kid event | |
] | |
] | |
] | |
event | |
] | |
face-offset: face-offset - face/offset | |
] | |
insert-event-func event-filter: func [face event][ | |
switch event/type [ | |
move [mouse-offset: event/offset] | |
scroll-line [catch [step-through/window event/face event]] | |
scroll-page [catch [step-through/window event/face event]] | |
] | |
event | |
] | |
] | |
view layout [ | |
style scroll-box box coal 300x100 "Scroll Box" feel [ | |
scroller: func [face event][ | |
face/text: reform [event/type event/offset] | |
show face | |
] | |
] | |
scroll-box | |
box coal 300x100 "Not Scroll Box" | |
panel [scroll-box] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Re: Mouse Wheel Useless?