diff options
| author | Stefan Küng <unknown> | 2016-09-27 10:03:48 +1000 | 
|---|---|---|
| committer | Stefan Küng <unknown> | 2016-09-27 10:03:48 +1000 | 
| commit | 073480a615d644f8c61e339a500243db00989a80 (patch) | |
| tree | af17b04b82906aa15e6263a95688c53c1a86d963 | |
| parent | aad4df63986f194a86cd669769d5efb5872b6c1a (diff) | |
| download | scintilla-mirror-073480a615d644f8c61e339a500243db00989a80.tar.gz | |
On Win32, mouse wheel scrolling can be restricted to only occur when the mouse
is within the window.
| -rw-r--r-- | doc/ScintillaDoc.html | 11 | ||||
| -rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
| -rw-r--r-- | include/Scintilla.h | 2 | ||||
| -rw-r--r-- | include/Scintilla.iface | 5 | ||||
| -rw-r--r-- | src/Editor.cxx | 8 | ||||
| -rw-r--r-- | src/Editor.h | 1 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 12 | 
7 files changed, 43 insertions, 0 deletions
| 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 {      <h2 id="MouseCapture">Mouse capture</h2>      <a class="message" href="#SCI_SETMOUSEDOWNCAPTURES">SCI_SETMOUSEDOWNCAPTURES(bool captures)</a><br />       <a class="message" href="#SCI_GETMOUSEDOWNCAPTURES">SCI_GETMOUSEDOWNCAPTURES</a><br /> +     <a class="message" href="#SCI_SETMOUSEWHEELCAPTURES">SCI_SETMOUSEWHEELCAPTURES(bool captures)</a><br /> +     <a class="message" href="#SCI_GETMOUSEWHEELCAPTURES">SCI_GETMOUSEWHEELCAPTURES</a><br />      <p><b id="SCI_SETMOUSEDOWNCAPTURES">SCI_SETMOUSEDOWNCAPTURES(bool captures)</b><br />       <b id="SCI_GETMOUSEDOWNCAPTURES">SCI_GETMOUSEDOWNCAPTURES</b><br /> @@ -2238,6 +2240,15 @@ struct Sci_TextToFind {      sent to Scintilla. This behaviour may be turned off with      <code>SCI_SETMOUSEDOWNCAPTURES(0)</code>.</p> +    <p><b id="SCI_SETMOUSEWHEELCAPTURES">SCI_SETMOUSEWHEELCAPTURES(bool captures)</b><br /> +     <b id="SCI_GETMOUSEWHEELCAPTURES">SCI_GETMOUSEWHEELCAPTURES</b><br /> +     On Windows, Scintilla captures all <code>WM_MOUSEWHEEL</code> messages if it has the +     focus, even if the mouse pointer is nowhere near the Scintilla editor window. This +     behavior can be changed with <code>SCI_SETMOUSEWHEELCAPTURES(0)</code> so that +     Scintilla passes the <code>WM_MOUSEWHEEL</code> messages to its parent window. +     Scintilla will still react to the mouse wheel if the mouse pointer is over +     the editor window.</p> +      <h2 id="LineEndings">Line endings</h2>      <p>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.  	<li> +	<li> +	On Win32, mouse wheel scrolling can be restricted to only occur when the mouse is +	within the window. +	<li>  	The WordList class in lexlib used by lexers adds an InListAbridged method for  	matching keywords that have particular prefixes and/or suffixes.  	</li> 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<int>(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<HWND>(ac.lb->GetID()); | 
