diff options
author | nyamatongwe <devnull@localhost> | 2001-08-08 09:42:13 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2001-08-08 09:42:13 +0000 |
commit | feb80a2c787c3d9b46557acb3b8317e6e3dc5d22 (patch) | |
tree | 10dc90bddd4c576ac9483d3e670b4abc8ce92347 | |
parent | 46ade7fb100ba43e6814a9b5297afa6c491cb244 (diff) | |
download | scintilla-mirror-feb80a2c787c3d9b46557acb3b8317e6e3dc5d22.tar.gz |
Added mouse dwell feature.
-rw-r--r-- | include/Scintilla.h | 9 | ||||
-rw-r--r-- | include/Scintilla.iface | 10 | ||||
-rw-r--r-- | src/Editor.cxx | 38 | ||||
-rw-r--r-- | src/Editor.h | 4 |
4 files changed, 57 insertions, 4 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h index ac7614804..65a95b8e9 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -338,6 +338,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETTABINDENTS 2261 #define SCI_SETBACKSPACEUNINDENTS 2262 #define SCI_GETBACKSPACEUNINDENTS 2263 +#define SC_TIME_FOREVER 10000000 +#define SCI_SETMOUSEDWELLTIME 2264 +#define SCI_GETMOUSEDWELLTIME 2265 #define SCI_LINEDOWN 2300 #define SCI_LINEDOWNEXTEND 2301 #define SCI_LINEUP 2302 @@ -498,6 +501,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_PAINTED 2013 #define SCN_USERLISTSELECTION 2014 #define SCN_URIDROPPED 2015 +#define SCN_DWELLSTART 2016 +#define SCN_DWELLEND 2017 //--Autogenerated -- end of section automatically generated from Scintilla.iface // Optional module for macro recording @@ -552,7 +557,7 @@ struct NotifyHeader { struct SCNotification { struct NotifyHeader nmhdr; - int position; // SCN_STYLENEEDED, SCN_MODIFIED + int position; // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND int ch; // SCN_CHARADDED, SCN_KEY int modifiers; // SCN_KEY int modificationType; // SCN_MODIFIED @@ -569,6 +574,8 @@ struct SCNotification { int foldLevelPrev; // SCN_MODIFIED int margin; // SCN_MARGINCLICK int listType; // SCN_USERLISTSELECTION + int x; // SCN_DWELLSTART, SCN_DWELLEND + int y; // SCN_DWELLSTART, SCN_DWELLEND }; #define SC_MASK_FOLDERS ((1<<SC_MARKNUM_FOLDER) | \ diff --git a/include/Scintilla.iface b/include/Scintilla.iface index abfe7aba9..bb40634f3 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -858,6 +858,14 @@ set void SetBackSpaceUnIndents=2262(bool bsUnIndents,) # Does a backspace pressed when caret is within indentation unindent? get bool GetBackSpaceUnIndents=2263(,) +val SC_TIME_FOREVER=10000000 + +# Sets the time the mouse must sit still to generate a mouse dwell event +set void SetMouseDwellTime=2264(int periodMilliseconds,) + +# Retrieve the time the mouse must sit still to generate a mouse dwell event +get int GetMouseDwellTime=2265(,) + ## Start of key messages # Move caret down one line. fun void LineDown=2300(,) @@ -1550,6 +1558,8 @@ evt void PosChanged=2012(int position) evt void Painted=2013(void) evt void UserListSelection=2014(int listType, string text) evt void URIDropped=2015(string text) +evt void DwellStart=2016(int position) +evt void DwellEnd=2017(int position) cat Deprecated diff --git a/src/Editor.cxx b/src/Editor.cxx index 7c44dfb0c..1416fad8f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -53,6 +53,9 @@ Editor::Editor() { bufferedDraw = true; lastClickTime = 0; + dwellDelay = SC_TIME_FOREVER; + ticksToDwell = SC_TIME_FOREVER; + dwelling = false; ptMouseLast.x = 0; ptMouseLast.y = 0; firstExpose = true; @@ -1937,6 +1940,15 @@ void Editor::NotifyNeedShown(int pos, int len) { NotifyParent(scn); } +void Editor::NotifyDwelling(Point pt, bool state) { + SCNotification scn; + scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; + scn.position = PositionFromLocation(pt); + scn.x = pt.x; + scn.y = pt.y; + NotifyParent(scn); +} + // Notifications from document void Editor::NotifyModifyAttempt(Document*, void *) { //Platform::DebugPrintf("** Modify Attempt\n"); @@ -3034,8 +3046,6 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b //lineAnchor = lineStart; // Keep the same anchor for ButtonMove } - - SetDragPosition(invalidPosition); SetMouseCapture(true); selectionType = selLine; @@ -3067,6 +3077,14 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } void Editor::ButtonMove(Point pt) { + if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) { + ticksToDwell = dwellDelay; + if (dwelling && (dwellDelay < SC_TIME_FOREVER)) { + dwelling = false; + NotifyDwelling(ptMouseLast, dwelling); + } + } + ptMouseLast = pt; //Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y); if (HaveMouseCapture()) { @@ -3078,7 +3096,6 @@ void Editor::ButtonMove(Point pt) { // Adjust selection xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; - ptMouseLast = pt; int movePos = PositionFromLocation(pt); movePos = MovePositionOutsideChar(movePos, currentPos - movePos); if (posDrag >= 0) { @@ -3201,6 +3218,13 @@ void Editor::Tick() { InvalidateCaret(); } } + if ((dwellDelay < SC_TIME_FOREVER) && (ticksToDwell > 0)) { + ticksToDwell -= timer.tickSize; + if (ticksToDwell <= 0) { + dwelling = true; + NotifyDwelling(ptMouseLast, dwelling); + } + } } void Editor::SetFocusState(bool focusState) { @@ -4231,6 +4255,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETBACKSPACEUNINDENTS: return pdoc->backspaceUnindents; + case SCI_SETMOUSEDWELLTIME: + dwellDelay = wParam; + ticksToDwell = dwellDelay; + break; + + case SCI_GETMOUSEDWELLTIME: + return dwellDelay; + case SCI_GETCOLUMN: return pdoc->GetColumn(wParam); diff --git a/src/Editor.h b/src/Editor.h index 0338467aa..5fdbbfae7 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -104,6 +104,9 @@ protected: // ScintillaBase subclass needs access to much of Editor Point lastClick; unsigned int lastClickTime; + int dwellDelay; + int ticksToDwell; + bool dwelling; enum { selChar, selWord, selLine } selectionType; Point ptMouseLast; bool firstExpose; @@ -259,6 +262,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyPainted(); bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); void NotifyNeedShown(int pos, int len); + void NotifyDwelling(Point pt, bool state); void NotifyModifyAttempt(Document *document, void *userData); void NotifySavePoint(Document *document, void *userData, bool atSavePoint); |