Skip to content

Commit

Permalink
simpler key mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
onekiloparsec committed Jan 15, 2017
1 parent bdb78ca commit 2172d36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
21 changes: 5 additions & 16 deletions KPCJumpBarControl/JumpBarControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,11 @@ open class JumpBarControl: NSControl, JumpBarSegmentControlDelegate {

// MARK: - Activation

open func makeKey() {
self.isKey = true
for segmentControl in self.segmentControls() {
segmentControl.makeKey()
}
open func makeKey(_ flag: Bool) {
self.isKey = flag
self.segmentControls().forEach { $0.makeKey(flag) }
self.setNeedsDisplay()
}

open func resignKey() {
self.isKey = false
for segmentControl in self.segmentControls() {
segmentControl.resignKey()
}
self.setNeedsDisplay()
}

}

// MARK: - Layout

Expand Down Expand Up @@ -307,7 +296,7 @@ open class JumpBarControl: NSControl, JumpBarSegmentControlDelegate {
let segment = self.segmentControlAtLevel(position)!
segment.isLastSegment = (position == self.selectedIndexPath!.count-1)
segment.indexInPath = index
segment.makeKey()
segment.makeKey(true)

let item = currentMenu!.item(at: index)
segment.representedObject = item!.representedObject as? JumpBarItem
Expand Down
11 changes: 3 additions & 8 deletions KPCJumpBarControl/JumpBarSegmentControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,11 @@ class JumpBarSegmentControl : NSControl {
return w
}

func makeKey() {
self.isKey = true
func makeKey(_ flag: Bool) {
self.isKey = flag
self.setNeedsDisplay()
}

func resignKey() {
self.isKey = false
self.setNeedsDisplay()
}


// MARK: Delegate

override func mouseDown(with theEvent: NSEvent) {
Expand Down

0 comments on commit 2172d36

Please sign in to comment.