4 Commits
Author SHA1 Message Date
acheronfail f6f8ea731c version: 1.4.0 2019-08-31 10:01:35 +10:00
acheronfail 5f2ece38fc chore: add HJKL keybindings to the README 2019-08-31 09:59:54 +10:00
acheronfail 4cad2a9db3 Merge pull request #24 from adrianniebla/pixel_navigation
Added vim style navigation to pixel picker.
2019-08-31 09:56:29 +10:00
Adrian Samuel Niebla Rios e4fe3e9d43 Added vim style navigation to pixel picker. 2019-08-30 16:31:29 -05:00
3 changed files with 42 additions and 2 deletions
+2 -2
View File
@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.6</string>
<string>1.4.0</string>
<key>CFBundleVersion</key>
<string>16</string>
<string>17</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
@@ -110,11 +110,41 @@ class PPOverlayController: NSWindowController {
case kVK_RightArrow:
PPState.shared.chosenFormat = PPState.shared.chosenFormat.next()
updateInfoPanel(lastHighlightedColor, lastHighlightedColor.bestContrastingColor())
case kVK_ANSI_K:
moveByPixel(dx: 0.0, dy: 1.0)
// Move up
break
case kVK_ANSI_J:
moveByPixel(dx: 0.0, dy: -1.0)
// Move down
break
case kVK_ANSI_H:
moveByPixel(dx: -1.0, dy: 0.0)
// Move left
break
case kVK_ANSI_L:
moveByPixel(dx: 1.0, dy: 0.0)
// Move right
break
default:
break
}
}
func moveByPixel(dx: CGFloat, dy: CGFloat) {
var mouseLoc = lastMouseLocation
let currentScreen = getScreenWithMouse()
guard let screenFrame = currentScreen?.frame, let screenScale = currentScreen?.backingScaleFactor else {
return
}
mouseLoc.x += dx / screenScale
mouseLoc.y += dy / screenScale
lastMouseLocation = mouseLoc
updatePreview(aroundPoint: mouseLoc)
mouseLoc.y = screenFrame.maxY - mouseLoc.y
CGDisplayMoveCursorToPoint(0, mouseLoc)
}
// Enable "focusMode" when correct modifier flag is changed.
override func flagsChanged(with event: NSEvent) {
if isEnabled {
@@ -228,6 +258,15 @@ class PPOverlayController: NSWindowController {
infoPanel.setFrame(rect, display: false)
}
// Get the screen that current has displayed the mouse.
func getScreenWithMouse() -> NSScreen? {
let mouseLocation = NSEvent.mouseLocation
let screens = NSScreen.screens
let screenWithMouse = (screens.first { NSMouseInRect(mouseLocation, $0.frame, false) })
return screenWithMouse
}
// Updates the info panel with the correct colors and text.
func updateInfoPanel(_ color: NSColor, _ contrastingColor: NSColor) {
infoWrapper.layer?.backgroundColor = color.cgColor
+1
View File
@@ -34,6 +34,7 @@ After you've installed Pixel Picker, it will live in your menu bar. You have man
* Configure a keyboard shortcut in the dropdown menu and press that to activate the picker
* Select the "Pick a Pixel" item in the dropdown menu to activate the picker
* Simply right-click the menu item and the picker will activate
* _Pro-tip:_ Use the <kbd>H</kbd>, <kbd>J</kbd>, <kbd>K</kbd> and <kbd>L</kbd> keys to move the picker pixel by pixel
Once you have the picker open, it should be quite straightforward! Move your mouse around the screen and click (or press <kbd>space</kbd> on the pixel you want.
You can also hold down the <kbd>control (⌃)</kbd> key (this can be changed to another key) while the picker is open, and the picker will enter "Focus Mode". This will zoom the pixel preview even further, and will slow down the picker's movement to make it easier to pick that hard-to-get pixel!