From 073480a615d644f8c61e339a500243db00989a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=BCng?= Date: Tue, 27 Sep 2016 10:03:48 +1000 Subject: On Win32, mouse wheel scrolling can be restricted to only occur when the mouse is within the window. --- doc/ScintillaDoc.html | 11 +++++++++++ doc/ScintillaHistory.html | 4 ++++ include/Scintilla.h | 2 ++ include/Scintilla.iface | 5 +++++ src/Editor.cxx | 8 ++++++++ src/Editor.h | 1 + win32/ScintillaWin.cxx | 12 ++++++++++++ 7 files changed, 43 insertions(+) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 681970d93..b348a68b7 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -2231,6 +2231,8 @@ struct Sci_TextToFind {

Mouse capture

SCI_SETMOUSEDOWNCAPTURES(bool captures)
SCI_GETMOUSEDOWNCAPTURES
+ SCI_SETMOUSEWHEELCAPTURES(bool captures)
+ SCI_GETMOUSEWHEELCAPTURES

SCI_SETMOUSEDOWNCAPTURES(bool captures)
SCI_GETMOUSEDOWNCAPTURES
@@ -2238,6 +2240,15 @@ struct Sci_TextToFind { sent to Scintilla. This behaviour may be turned off with SCI_SETMOUSEDOWNCAPTURES(0).

+

SCI_SETMOUSEWHEELCAPTURES(bool captures)
+ SCI_GETMOUSEWHEELCAPTURES
+ On Windows, Scintilla captures all WM_MOUSEWHEEL messages if it has the + focus, even if the mouse pointer is nowhere near the Scintilla editor window. This + behavior can be changed with SCI_SETMOUSEWHEELCAPTURES(0) so that + Scintilla passes the WM_MOUSEWHEEL messages to its parent window. + Scintilla will still react to the mouse wheel if the mouse pointer is over + the editor window.

+

Line endings

Scintilla can handle the major line end conventions and, depending on settings and diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 99ae922f1..a6079cfeb 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -530,6 +530,10 @@ EDGE_MULTILINE and SCI_MULTIEDGEADDLINE added to allow displaying multiple vertical edges simultaneously.

  • +
  • + On Win32, mouse wheel scrolling can be restricted to only occur when the mouse is + within the window. +
  • The WordList class in lexlib used by lexers adds an InListAbridged method for matching keywords that have particular prefixes and/or suffixes.
  • diff --git a/include/Scintilla.h b/include/Scintilla.h index 0b5483043..2d6b06b22 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -682,6 +682,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETSTATUS 2383 #define SCI_SETMOUSEDOWNCAPTURES 2384 #define SCI_GETMOUSEDOWNCAPTURES 2385 +#define SCI_SETMOUSEWHEELCAPTURES 2696 +#define SCI_GETMOUSEWHEELCAPTURES 2697 #define SC_CURSORNORMAL -1 #define SC_CURSORARROW 2 #define SC_CURSORWAIT 4 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index d52c229bf..bee9aeef8 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1755,6 +1755,11 @@ set void SetMouseDownCaptures=2384(bool captures,) # Get whether mouse gets captured. get bool GetMouseDownCaptures=2385(,) +# Set whether the mouse wheel can be active outside the window. +set void SetMouseWheelCaptures=2696(bool captures,) +# Get whether mouse wheel can be active outside the window. +get bool GetMouseWheelCaptures=2697(,) + enu CursorShape=SC_CURSOR val SC_CURSORNORMAL=-1 val SC_CURSORARROW=2 diff --git a/src/Editor.cxx b/src/Editor.cxx index beec634d3..ee4d3947f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -112,6 +112,7 @@ Editor::Editor() { hasFocus = false; errorStatus = 0; mouseDownCaptures = true; + mouseWheelCaptures = true; lastClickTime = 0; doubleClickCloseThreshold = Point(3, 3); @@ -7594,6 +7595,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETMOUSEDOWNCAPTURES: return mouseDownCaptures; + case SCI_SETMOUSEWHEELCAPTURES: + mouseWheelCaptures = wParam != 0; + break; + + case SCI_GETMOUSEWHEELCAPTURES: + return mouseWheelCaptures; + case SCI_SETCURSOR: cursorMode = static_cast(wParam); DisplayCursor(Window::cursorText); diff --git a/src/Editor.h b/src/Editor.h index 72d4719ed..ee56700dd 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -176,6 +176,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool hasFocus; bool mouseDownCaptures; + bool mouseWheelCaptures; int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret bool horizontalScrollBarVisible; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 10d119b5a..3de78d1d4 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -1272,6 +1272,18 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam break; case WM_MOUSEWHEEL: + if (!mouseWheelCaptures) { + // if the mouse wheel is not captured, test if the mouse + // pointer is over the editor window and if not, don't + // handle the message but pass it on. + RECT rc; + GetWindowRect(MainHWND(), &rc); + POINT pt; + pt.x = GET_X_LPARAM(lParam); + pt.y = GET_Y_LPARAM(lParam); + if (!PtInRect(&rc, pt)) + return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); + } // if autocomplete list active then send mousewheel message to it if (ac.Active()) { HWND hWnd = static_cast(ac.lb->GetID()); -- cgit v1.2.3