From 5881a28110acb48460b458cec763f8e7f4649477 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 3 Aug 2017 18:03:58 -0400 Subject: [PATCH] Use blue cursor --- writeas.xcodeproj/project.pbxproj | 4 ++++ writeas/Base.lproj/Main.storyboard | 2 +- writeas/TextField.swift | 33 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 writeas/TextField.swift diff --git a/writeas.xcodeproj/project.pbxproj b/writeas.xcodeproj/project.pbxproj index 124001b..f2195c5 100644 --- a/writeas.xcodeproj/project.pbxproj +++ b/writeas.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 33071005A600B8C542D04637 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33071BEC2D76387CC2ACE1BD /* WindowController.swift */; }; 330711A70F03BFB84FB889AB /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33071648B80C4188CAC44CA1 /* Constants.swift */; }; 33071853C7159177EC75175B /* Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = 330715DBB45C2BB18057D4BC /* Document.swift */; }; + 33071A66CAF656DB9C22D191 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33071D0D4955060F4888D328 /* TextField.swift */; }; 33071D332D5799D36FBC1DDD /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3307150C0D2CA1C8A71C5E26 /* Preferences.swift */; }; C98EE9AC1F29532F002F646E /* writeas in Resources */ = {isa = PBXBuildFile; fileRef = C98EE9AB1F29532F002F646E /* writeas */; }; C9953E801F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C9953E7C1F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-regular.ttf */; }; @@ -26,6 +27,7 @@ 330715DBB45C2BB18057D4BC /* Document.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Document.swift; path = writeas/Document.swift; sourceTree = ""; }; 33071648B80C4188CAC44CA1 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 33071BEC2D76387CC2ACE1BD /* WindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WindowController.swift; path = writeas/WindowController.swift; sourceTree = ""; }; + 33071D0D4955060F4888D328 /* TextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; C98EE9AB1F29532F002F646E /* writeas */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = writeas; sourceTree = ""; }; C9953E7C1F2D07A7008ED235 /* open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "open-sans-v14-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin_greek-ext_greek-regular.ttf"; sourceTree = ""; }; C9953E841F2D07BF008ED235 /* lora-v10-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin-regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "lora-v10-cyrillic-ext_vietnamese_cyrillic_latin-ext_latin-regular.ttf"; sourceTree = ""; }; @@ -89,6 +91,7 @@ C99B91121C33841F00A91990 /* Main.storyboard */, C99B91151C33841F00A91990 /* Info.plist */, 33071648B80C4188CAC44CA1 /* Constants.swift */, + 33071D0D4955060F4888D328 /* TextField.swift */, ); path = writeas; sourceTree = ""; @@ -176,6 +179,7 @@ 330711A70F03BFB84FB889AB /* Constants.swift in Sources */, 33071853C7159177EC75175B /* Document.swift in Sources */, 33071005A600B8C542D04637 /* WindowController.swift in Sources */, + 33071A66CAF656DB9C22D191 /* TextField.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/writeas/Base.lproj/Main.storyboard b/writeas/Base.lproj/Main.storyboard index d2c5f92..b434b61 100644 --- a/writeas/Base.lproj/Main.storyboard +++ b/writeas/Base.lproj/Main.storyboard @@ -439,7 +439,7 @@ DQ - + diff --git a/writeas/TextField.swift b/writeas/TextField.swift new file mode 100644 index 0000000..4bd45d9 --- /dev/null +++ b/writeas/TextField.swift @@ -0,0 +1,33 @@ +// +// Created by Matt Baer on 8/3/17. +// Copyright (c) 2017 A Bunch Tell. All rights reserved. +// + +import Foundation +import AppKit + +class TextField: NSTextView { + override func becomeFirstResponder() -> Bool { + let success = super.becomeFirstResponder() + if success { + // #5ac4ee + self.insertionPointColor = NSColor(red:0.35, green:0.77, blue:0.93, alpha:1.0) + } + + return success + } + + override func drawInsertionPoint(in rect: NSRect, color: NSColor, turnedOn flag: Bool) { + /* + if flag { + var rect = rect + var color = self.insertionPointColor + rect.size.width = 2 + let path = NSBezierPath(rect: rect) + path.setClip() + path.fill() + } + */ + super.drawInsertionPoint(in: rect, color: color, turnedOn: flag) + } +}