Working with Layers
QXML for layer
Layer is represented by the <qx-layer> node. It contains the following attributes:
|
Attribute |
Value |
Description |
|
|
text |
Name of layer |
|
|
number |
Unique ID of layer as generated by QuarkXPress |
Create new layer
To create a new layer:
-
Get the DOM of the active layout.
-
Create a new
<qx-layer>element. -
Set the
layer-nameattribute in the<qx-layer>element. -
Append the
<qx-layer>element as a child of the<qx-layout>node.
Sample JavaScript:
var layout = app.activeLayoutDOM();
var layer = document.createElement('qx-layer');
layer.setAttribute('layer-name','My Layer');
layout.appendChild(layer);
Delete an existing layer
To delete an existing layer:
-
Get the DOM of the active layout.
-
Get the
<qx-layer>node corresponding to the layer to be deleted. -
Remove the
<qx-layer>child node from the<qx-layout>node.
Sample JavaScript:
var layout = app.activeLayoutDOM();
var layer = layout.querySelector("qx-layer[layer-name='My Layer']");
layout.removeChild(layer);
Hide a layer
To hide a layer:
-
Get the DOM of the active layout.
-
Get the
<qx-layer>node . -
Set the
qxVisibilitystyling attribute tohidden.
var layout = app.activeLayoutDOM();
var layer = layout.querySelector("qx-layer[layer-name='My Layer']");
layer.style.qxVisibility = 'hidden';
Lock a layer
To lock a layer:
-
Get the DOM of the active layout.
-
Get the
<qx-layer>node . -
Set the
qxLockedstyling attribute totrue.
var layout = app.activeLayoutDOM();
var layer = layout.querySelector("qx-layer[layer-name='My Layer']");
layer.style.qxLocked = 'true';
Suppress output for a layer
To suppress output for a layer:
-
Get the DOM of the active layout.
-
Get the
<qx-layer>node . -
Set the
qxSuppressOutputstyling attribute totrue.
var layout = app.activeLayoutDOM();
var layer = layout.querySelector("qx-layer[layer-name='My Layer']");
layer.style.qxSuppressOutput = 'true';
Keep runaround for layer
To remote keep runaround property for a layer:
-
Get the DOM of the active layout.
-
Get the
<qx-layer>node . -
Set the
qxKeepRunaroundstyling attribute tofalse.
var layout = app.activeLayoutDOM();
var layer = layout.querySelector("qx-layer[layer-name='My Layer']");
layer.style.qxKeepRunaround = 'false';
Specify layer color
To specify the color for a layer using RGB values:
-
Get the DOM of the active layout.
-
Get the
<qx-layer>node . -
Specify the RGB color value
qxColorstyling attribute.var layout = app.activeLayoutDOM(); var layer = layout.querySelector("qx-layer[layer-name='My Layer']"); layer.style.qxColor= 'rgb(240,55, 217)';