diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2018-05-01 15:31:04 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2018-05-01 15:31:04 +1000 |
commit | f8558fd3e20dd92e30a10753854219b9a1bab9c4 (patch) | |
tree | c6a70a322189d99f1546c3d654f87e540c02c919 | |
parent | 070f233c37da20dd159e5a8b241e40c19591451c (diff) | |
download | scintilla-mirror-f8558fd3e20dd92e30a10753854219b9a1bab9c4.tar.gz |
Hoist conversion between NSEvent time and Editor method time into function.
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index a7e2cff65..9b97f2470 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2267,6 +2267,20 @@ void ScintillaCocoa::SetDocPointer(Document *document) { //-------------------------------------------------------------------------------------------------- /** + * Convert NSEvent timestamp NSTimeInterval into unsigned int milliseconds wanted by Editor methods. + */ + +namespace { + +unsigned int TimeOfEvent(NSEvent *event) { + return static_cast<unsigned int>(event.timestamp * 1000); +} + +} + +//-------------------------------------------------------------------------------------------------- + +/** * Called by the owning view when the mouse pointer enters the control. */ void ScintillaCocoa::MouseEntered(NSEvent *event) { @@ -2276,7 +2290,7 @@ void ScintillaCocoa::MouseEntered(NSEvent *event) { // Mouse location is given in screen coordinates and might also be outside of our bounds. Point location = ConvertPoint(event.locationInWindow); ButtonMoveWithModifiers(location, - (int)(event.timestamp * 1000), + TimeOfEvent(event), TranslateModifierFlags(event.modifierFlags)); } } @@ -2292,14 +2306,14 @@ void ScintillaCocoa::MouseExited(NSEvent * /* event */) { void ScintillaCocoa::MouseDown(NSEvent *event) { Point location = ConvertPoint(event.locationInWindow); ButtonDownWithModifiers(location, - (int)(event.timestamp * 1000), + TimeOfEvent(event), TranslateModifierFlags(event.modifierFlags)); } void ScintillaCocoa::RightMouseDown(NSEvent *event) { Point location = ConvertPoint(event.locationInWindow); RightButtonDownWithModifiers(location, - (int)(event.timestamp * 1000), + TimeOfEvent(event), TranslateModifierFlags(event.modifierFlags)); } @@ -2309,7 +2323,7 @@ void ScintillaCocoa::MouseMove(NSEvent *event) { lastMouseEvent = event; ButtonMoveWithModifiers(ConvertPoint(event.locationInWindow), - (int)(event.timestamp * 1000), + TimeOfEvent(event), TranslateModifierFlags(event.modifierFlags)); } @@ -2317,7 +2331,7 @@ void ScintillaCocoa::MouseMove(NSEvent *event) { void ScintillaCocoa::MouseUp(NSEvent *event) { ButtonUpWithModifiers(ConvertPoint(event.locationInWindow), - (int)(event.timestamp * 1000), + TimeOfEvent(event), TranslateModifierFlags(event.modifierFlags)); } |