正如标题所述,我想知道我的 CEP扩展名是否可以以及如何收听以选择事件,但仅适用于< strong> historyState ,而不是仅当我选择一个图层时。这是我的扩展程序如何监听选择事件的示例...
JS
(function()
{
'use strict';
var csInterface = new CSInterface();
function Register(inOn)
{
if (inOn)
{
var event = new CSEvent("com.adobe.PhotoshopRegisterEvent", "APPLICATION");
}
else
{
var event = new CSEvent("com.adobe.PhotoshopUnRegisterEvent", "APPLICATION");
};
event.extensionId = "my_extension_id";
// #region // EVENT CODES //
// ╔════════╦═════════╦════════════╗
// ║ Name ║ Char ID ║ Type ID ║
// ╠════════╬═════════╬════════════╣
// ║ Hide ║ Hd ║ 1214521376 ║
// ║ Select ║ slct ║ 1936483188 ║
// ║ Set ║ setd ║ 1936028772 ║
// ║ Show ║ Shw ║ 1399355168 ║
// ╚════════╩═════════╩════════════╝
// #endregion
event.data = "1936483188";
csInterface.dispatchEvent(event);
}
function init()
{
themeManager.init();
$('#registerEvent').change(function()
{
Register($(this).is(':checked'));
});
};
function PSCallback(csEvent)
{
var dataArray = csEvent.data.split(",");
csInterface.evalScript('convertTypeID(' + JSON.stringify(dataArray\[0\]) + ')', function(res)
{
$('#result').val(res.toString());
});
};
init();
csInterface.addEventListener("PhotoshopCallback", PSCallback);
}());
JSX
function convertTypeID (typeArray)
{
return typeIDToStringID(Number(typeArray));
};