Floating Panels > The floating panel API > selectionChanged() |
Description
Called when the floating panel becomes visible and when the selection changes (when focus switches to a new document or when the insertion pointer moves to a new location in the current document). This function should be defined only if the floating panel must track the selection.
Note: Define selectionChanged() only if you absolutely require it because its existence impacts performance.
Arguments
None.
Returns
Nothing.
Example
The following instance of selectionChanged() shows a different panel (layer) in the floating panel depending on whether the selection is a script marker or something else:
function selectionChanged(){
/* get the selected node */
var theDOM = dw.getDocumentDOM();
var theNode = dw.getSelectedNode();
/* check to see if the node is a script marker */
if (theNode.nodeType == Node.ELEMENT_NODE && theNode.¬
tagName == "SCRIPT"){
document.layers['blanklayer'].visibility = 'hidden';
document.layers['scriptlayer'].visibility = 'visible';
}else{
document.layers['scriptlayer'].visibility = 'hidden';
document.layers['blanklayer'].visibility = 'visible';
}
}