aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/ScintillaCocoa.h6
-rw-r--r--cocoa/ScintillaCocoa.mm36
-rw-r--r--cocoa/ScintillaView.mm4
3 files changed, 34 insertions, 12 deletions
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h
index 841ba8f13..d07ffe758 100644
--- a/cocoa/ScintillaCocoa.h
+++ b/cocoa/ScintillaCocoa.h
@@ -97,6 +97,8 @@ private:
intptr_t notifyObj;
bool capturedMouse;
+ bool isFirstResponder;
+ bool isActive;
bool enteredSetScrollingSize;
@@ -242,7 +244,9 @@ public:
NSMenu *CreateContextMenu(NSEvent *event);
void HandleCommand(NSInteger command);
- void ActiveStateChanged(bool isActive);
+ void SetFirstResponder(bool isFirstResponder_);
+ void ActiveStateChanged(bool isActive_);
+ void SetFocusActiveState();
void WindowWillMove();
// Find indicator
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 36ae35bd0..c4569144e 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -402,6 +402,8 @@ ScintillaCocoa::ScintillaCocoa(ScintillaView *sciView_, SCIContentView *viewCont
notifyObj = NULL;
notifyProc = NULL;
capturedMouse = false;
+ isFirstResponder = false;
+ isActive = false;
enteredSetScrollingSize = false;
scrollSpeed = 1;
scrollTicks = 2000;
@@ -2494,15 +2496,31 @@ void ScintillaCocoa::HandleCommand(NSInteger command) {
//--------------------------------------------------------------------------------------------------
-void ScintillaCocoa::ActiveStateChanged(bool isActive) {
- // If the window is being deactivated, lose the focus and turn off the ticking
- if (!isActive) {
- DropCaret();
- //SetFocusState( false );
- FineTickerCancel(TickReason::caret);
- } else {
- ShowCaretAtCurrentPosition();
- }
+/**
+ * Update 'isFirstResponder' and possibly change focus state.
+ */
+void ScintillaCocoa::SetFirstResponder(bool isFirstResponder_) {
+ isFirstResponder = isFirstResponder_;
+ SetFocusActiveState();
+}
+
+//--------------------------------------------------------------------------------------------------
+
+/**
+ * Update 'isActive' and possibly change focus state.
+ */
+void ScintillaCocoa::ActiveStateChanged(bool isActive_) {
+ isActive = isActive_;
+ SetFocusActiveState();
+}
+
+//--------------------------------------------------------------------------------------------------
+
+/**
+ * Update 'hasFocus' based on first responder and active status.
+ */
+void ScintillaCocoa::SetFocusActiveState() {
+ SetFocusState(isActive && isFirstResponder);
}
//--------------------------------------------------------------------------------------------------
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm
index c0b2ee950..593722c1e 100644
--- a/cocoa/ScintillaView.mm
+++ b/cocoa/ScintillaView.mm
@@ -772,7 +772,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* The editor is getting the foreground control (the one getting the input focus).
*/
- (BOOL) becomeFirstResponder {
- mOwner.backend->WndProc(SCI_SETFOCUS, 1, 0);
+ mOwner.backend->SetFirstResponder(true);
return YES;
}
@@ -782,7 +782,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* The editor is losing the input focus.
*/
- (BOOL) resignFirstResponder {
- mOwner.backend->WndProc(SCI_SETFOCUS, 0, 0);
+ mOwner.backend->SetFirstResponder(false);
return YES;
}