-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHotkey-ShowHideLayers.py
33 lines (25 loc) · 1.08 KB
/
Hotkey-ShowHideLayers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from mojo.UI import SetCurrentLayerByName
from mojo.events import addObserver, removeObserver
class ShowHideLayers():
"""
Startup Script:
Assigns the "h" key to show/hide layer outlines
-- Andy Clymer, github.com/andyclymer
"""
def __init__(self):
addObserver(self, "keyDown", "keyDown")
def keyDown(self, info):
event = info["event"]
characters = event.characters()
modifierFlags = event.modifierFlags()
if characters == "h":
f = CurrentFont()
if len(f.layerOrder) > 1:
nextLayer = f.layerOrder[1]
# Get the current display status for the first non-foreground layer
currentDisplayOption = f.getLayer(nextLayer).getDisplayOption()["Stroke"]
# Set the oppoosite display status on all other layers:
for layerName in f.layerOrder:
if not layerName == "foreground":
f.getLayer(layerName).setDisplayOption("Stroke", not currentDisplayOption)
ShowHideLayers()