mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
io/pointer,gesture,app/internal/window: add pointer.Scroll event type
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
This commit is contained in:
@@ -73,7 +73,7 @@ static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFlo
|
||||
- (void)scrollWheel:(NSEvent *)event {
|
||||
CGFloat dx = -event.scrollingDeltaX;
|
||||
CGFloat dy = -event.scrollingDeltaY;
|
||||
handleMouse(self, event, GIO_MOUSE_MOVE, dx, dy);
|
||||
handleMouse(self, event, GIO_MOUSE_SCROLL, dx, dy);
|
||||
}
|
||||
- (void)keyDown:(NSEvent *)event {
|
||||
NSString *keys = [event charactersIgnoringModifiers];
|
||||
|
||||
@@ -146,7 +146,7 @@ func (w *window) addEventListeners() {
|
||||
dx *= 120
|
||||
dy *= 120
|
||||
}
|
||||
w.pointerEvent(pointer.Move, float32(dx), float32(dy), e)
|
||||
w.pointerEvent(pointer.Scroll, float32(dx), float32(dy), e)
|
||||
return nil
|
||||
})
|
||||
w.addEventListener(w.cnv, "touchstart", func(this js.Value, args []js.Value) interface{} {
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
#define GIO_MOUSE_MOVE 1
|
||||
#define GIO_MOUSE_UP 2
|
||||
#define GIO_MOUSE_DOWN 3
|
||||
#define GIO_MOUSE_SCROLL 4
|
||||
|
||||
__attribute__ ((visibility ("hidden"))) void gio_main(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat height);
|
||||
__attribute__ ((visibility ("hidden"))) CGFloat gio_viewWidth(CFTypeRef viewRef);
|
||||
@@ -160,6 +161,8 @@ func gio_onMouse(view C.CFTypeRef, cdir C.int, cbtns C.NSUInteger, x, y, dx, dy
|
||||
typ = pointer.Release
|
||||
case C.GIO_MOUSE_DOWN:
|
||||
typ = pointer.Press
|
||||
case C.GIO_MOUSE_SCROLL:
|
||||
typ = pointer.Scroll
|
||||
default:
|
||||
panic("invalid direction")
|
||||
}
|
||||
|
||||
@@ -1293,7 +1293,7 @@ func (w *window) flushScroll() {
|
||||
return
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Move,
|
||||
Type: pointer.Scroll,
|
||||
Source: pointer.Mouse,
|
||||
Buttons: w.pointerBtns,
|
||||
Position: w.lastPos,
|
||||
|
||||
@@ -278,7 +278,7 @@ func (w *window) scrollEvent(wParam, lParam uintptr) {
|
||||
p := f32.Point{X: float32(np.X), Y: float32(np.Y)}
|
||||
dist := float32(int16(wParam >> 16))
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Move,
|
||||
Type: pointer.Scroll,
|
||||
Source: pointer.Mouse,
|
||||
Position: p,
|
||||
Buttons: w.pointerBtns,
|
||||
|
||||
@@ -310,11 +310,11 @@ func (h *x11EventHandler) handleEvents() bool {
|
||||
btn = pointer.ButtonRight
|
||||
case C.Button4:
|
||||
// scroll up
|
||||
ev.Type = pointer.Move
|
||||
ev.Type = pointer.Scroll
|
||||
ev.Scroll.Y = -scrollScale
|
||||
case C.Button5:
|
||||
// scroll down
|
||||
ev.Type = pointer.Move
|
||||
ev.Type = pointer.Scroll
|
||||
ev.Scroll.Y = +scrollScale
|
||||
default:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user