コード例 #1
0
ファイル: MonoWindow.cs プロジェクト: emclient/mac-playground
        protected virtual bool PreprocessScrollWheel(NSEvent e)
        {
            var view = (ContentView.Superview ?? ContentView).HitTest(e.LocationInWindow);

            if (view != null && !view.IsSwfControl() && Control.FromChildHandle(view.Handle) is Control control)
            {
                // This is to allow SWF wrappers of native views to handle messages before the native view swallows them (WebView, for example).

                var p = driver.NativeToMonoScreen(this.ConvertPointToScreenSafe(e.LocationInWindow));
                if (Math.Abs(e.ScrollingDeltaY - nfloat.Epsilon) > 0)
                {
                    var delta  = e.ScaledAndQuantizedDeltaY();
                    var wParam = (IntPtr)(((int)e.ModifiersToWParam() & 0xFFFF) | (delta << 16));
                    var lParam = (IntPtr)((p.X & 0xFFFF) | (p.Y << 16));
                    var msg    = new MSG {
                        hwnd = control.Handle, message = Msg.WM_MOUSEWHEEL, wParam = wParam, lParam = lParam
                    };
                    if (Application.SendMessage(ref msg, out var drop, out var _).ToInt32() == 0 || drop)
                    {
                        return(true);
                    }
                }

                if (Math.Abs(e.ScrollingDeltaX - nfloat.Epsilon) > 0)
                {
                    int delta  = e.ScaledAndQuantizedDeltaX();
                    var wParam = (IntPtr)(((int)e.ModifiersToWParam() & 0xFFFF) | (delta << 16));
                    var lParam = (IntPtr)((p.X & 0xFFFF) | (p.Y << 16));
                    var msg    = new MSG {
                        hwnd = control.Handle, message = Msg.WM_MOUSEHWHEEL, wParam = wParam, lParam = lParam
                    };
                    if (Application.SendMessage(ref msg, out var drop, out var _).ToInt32() == 0 || drop)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #2
0
        public override void ScrollWheel(NSEvent e)
        {
            var msg = TranslateMouseCore(e, out bool _);

            if (e.ScrollingDeltaY != 0)
            {
                int delta = e.ScaledAndQuantizedDeltaY();
                msg.message = Msg.WM_MOUSEWHEEL;
                msg.wParam  = (IntPtr)(((int)e.ModifiersToWParam() & 0xFFFF) | (delta << 16));
                msg.lParam  = (IntPtr)((msg.pt.x & 0xFFFF) | (msg.pt.y << 16));
                Application.SendMessage(ref msg);
            }

            if (e.ScrollingDeltaX != 0)
            {
                int delta = e.ScaledAndQuantizedDeltaX();
                msg.message = Msg.WM_MOUSEHWHEEL;
                msg.wParam  = (IntPtr)(((int)e.ModifiersToWParam() & 0xFFFF) | (delta << 16));
                msg.lParam  = (IntPtr)((msg.pt.x & 0xFFFF) | (msg.pt.y << 16));
                Application.SendMessage(ref msg);
            }
        }