aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2010-02-19 22:54:51 +0000
committernyamatongwe <unknown>2010-02-19 22:54:51 +0000
commit894ca126a2f73926df1f1eba0a5e875614e5ca43 (patch)
treee42f0fc1ce0e9fa00c6410287b71dd566e5df3a0
parent66c683a69a906bbca6e8fc812d07cc01091006d2 (diff)
downloadscintilla-mirror-894ca126a2f73926df1f1eba0a5e875614e5ca43.tar.gz
Fix for bug #2951353 HotSpotRange clearing when mouse moves out of window.
-rw-r--r--src/Editor.cxx7
-rw-r--r--src/Editor.h1
-rw-r--r--win32/ScintillaWin.cxx37
3 files changed, 44 insertions, 1 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 876be0004..f9f02788a 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5621,7 +5621,11 @@ void Editor::DwellEnd(bool mouseMoved) {
}
}
-static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) {
+void Editor::MouseLeave() {
+ SetHotSpotRange(NULL);
+}
+
+static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) {
return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0)
|| (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0));
}
@@ -5897,6 +5901,7 @@ void Editor::ButtonMove(Point pt) {
if (vs.fixedColumnWidth > 0) { // There is a margin
if (PointInSelMargin(pt)) {
DisplayCursor(Window::cursorReverseArrow);
+ SetHotSpotRange(NULL);
return; // No need to test for selection
}
}
diff --git a/src/Editor.h b/src/Editor.h
index ea3718ff3..94454b2d9 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -442,6 +442,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool PointInSelMargin(Point pt);
void LineSelection(int lineCurrent_, int lineAnchor_);
void DwellEnd(bool mouseMoved);
+ void MouseLeave();
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
void ButtonMove(Point pt);
void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index bdc4e1473..d7fd049b3 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -93,6 +93,8 @@ extern bool IsNT();
extern void Platform_Initialise(void *hInstance);
extern void Platform_Finalise();
+typedef BOOL (WINAPI *TrackMouseEventSig)(LPTRACKMOUSEEVENT);
+
/** TOTAL_CONTROL ifdef surrounds code that will only work when ScintillaWin
* is derived from ScintillaBase (all features) rather than directly from Editor
* (lightweight editor).
@@ -157,6 +159,8 @@ class ScintillaWin :
bool lastKeyDownConsumed;
bool capturedMouse;
+ bool trackedMouseLeave;
+ TrackMouseEventSig TrackMouseEventFn;
unsigned int linesPerScroll; ///< Intellimouse support
int wheelDelta; ///< Wheel delta from roll
@@ -203,6 +207,7 @@ class ScintillaWin :
virtual void SetTicking(bool on);
virtual void SetMouseCapture(bool on);
virtual bool HaveMouseCapture();
+ virtual void SetTrackMouseLeaveEvent(bool on);
virtual bool PaintContains(PRectangle rc);
virtual void ScrollText(int linesToMove);
virtual void UpdateSystemCaret();
@@ -298,6 +303,9 @@ ScintillaWin::ScintillaWin(HWND hwnd) {
lastKeyDownConsumed = false;
capturedMouse = false;
+ trackedMouseLeave = false;
+ TrackMouseEventFn = 0;
+
linesPerScroll = 0;
wheelDelta = 0; // Wheel delta from roll
@@ -338,6 +346,18 @@ void ScintillaWin::Initialise() {
// no effect. If the app hasnt, we really shouldnt ask them to call
// it just so this internal feature works.
hrOle = ::OleInitialize(NULL);
+
+ // Find TrackMouseEvent which is available on Windows > 95
+ HMODULE user32 = ::GetModuleHandle("user32.dll");
+ TrackMouseEventFn = (TrackMouseEventSig)::GetProcAddress(user32, "TrackMouseEvent");
+ if (TrackMouseEventFn == NULL) {
+ // Windows 95 has an emulation in comctl32.dll:_TrackMouseEvent
+ HMODULE commctrl32 = ::LoadLibrary("comctl32.dll");
+ if (commctrl32 != NULL) {
+ TrackMouseEventFn = (TrackMouseEventSig)
+ ::GetProcAddress(commctrl32, "_TrackMouseEvent");
+ }
+ }
}
void ScintillaWin::Finalise() {
@@ -731,9 +751,15 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case WM_MOUSEMOVE:
+ SetTrackMouseLeaveEvent(true);
ButtonMove(Point::FromLong(lParam));
break;
+ case WM_MOUSELEAVE:
+ SetTrackMouseLeaveEvent(false);
+ MouseLeave();
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+
case WM_LBUTTONUP:
ButtonUp(Point::FromLong(lParam),
::GetMessageTime(),
@@ -1101,6 +1127,17 @@ bool ScintillaWin::HaveMouseCapture() {
//return capturedMouse && (::GetCapture() == MainHWND());
}
+void ScintillaWin::SetTrackMouseLeaveEvent(bool on) {
+ if (on && TrackMouseEventFn && !trackedMouseLeave) {
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = MainHWND();
+ TrackMouseEventFn(&tme);
+ }
+ trackedMouseLeave = on;
+}
+
bool ScintillaWin::PaintContains(PRectangle rc) {
bool contains = true;
if ((paintState == painting) && (!rc.Empty())) {