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 | f57bf0fdab5a7fc041293c799c473132df4f73d0 (patch) | |
| tree | 3f818cacd1d67a4255a133dbefb8e5fd0a12b845 | |
| parent | c3a65f37eac66c61c9da89c6c847c65f528ea319 (diff) | |
| download | scintilla-mirror-f57bf0fdab5a7fc041293c799c473132df4f73d0.tar.gz | |
Backport: Hoist conversion between NSEvent time and Editor method time into function.
Backport of changeset 6776:21643ea8bb67.
| -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 7f655adbb..39f0a9726 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2394,6 +2394,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) @@ -2405,7 +2419,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])); } } @@ -2423,7 +2437,7 @@ void ScintillaCocoa::MouseDown(NSEvent* event) { Point location = ConvertPoint([event locationInWindow]); ButtonDownWithModifiers(location, - (int)([event timestamp] * 1000), + TimeOfEvent(event), TranslateModifierFlags([event modifierFlags])); } @@ -2431,7 +2445,7 @@ void ScintillaCocoa::RightMouseDown(NSEvent *event) { Point location = ConvertPoint([event locationInWindow]); RightButtonDownWithModifiers(location, - (int)([event timestamp] * 1000), + TimeOfEvent(event), TranslateModifierFlags([event modifierFlags])); } @@ -2441,7 +2455,7 @@ void ScintillaCocoa::MouseMove(NSEvent* event) { lastMouseEvent = event; - ButtonMoveWithModifiers(ConvertPoint([event locationInWindow]), (int)([event timestamp] * 1000), TranslateModifierFlags([event modifierFlags])); + ButtonMoveWithModifiers(ConvertPoint([event locationInWindow]), TimeOfEvent(event), TranslateModifierFlags([event modifierFlags])); } //-------------------------------------------------------------------------------------------------- @@ -2449,7 +2463,7 @@ void ScintillaCocoa::MouseMove(NSEvent* event) void ScintillaCocoa::MouseUp(NSEvent* event) { ButtonUpWithModifiers(ConvertPoint([event locationInWindow]), - (int)([event timestamp] * 1000), + TimeOfEvent(event), TranslateModifierFlags([event modifierFlags])); } |
