Page 1 of 1

How my CEP extension can listen to [Select] event but only for [historyState]?

Posted: Fri Nov 08, 2019 9:20 am
by Simonetos The Greek
As the title says, I would like to know if and how my CEP extension can listen to Select event, but only for historyState and not when I just select a layer for example. Here is an example how my extension listens to Select event...

HTML

Code: Select all

<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<link id="hostStyle" rel="stylesheet" href="css/theme.css" />
		<link id="theme" rel="stylesheet" href="css/light.css" />
		<title></title>
	</head>
	<body>
		<div style="width: 80%; margin:0 auto">
			<h3 class="center">PS Events</h3>
			<label class="topcoat-switch">
				<input id="registerEvent" type="checkbox" class="topcoat-switch__input">
				<div class="topcoat-switch__toggle"></div>
			</label>
			<input type="text" id="result" class="topcoat-text-input" style="margin-left:10px" placeholder="Listen for Events" value="">
		</div>
		<script src="js/libs/CSInterface.js"></script>
		<script src="js/libs/jquery-2.0.2.min.js"></script>
		<script src="js/themeManager.js"></script>
		<script src="js/main.js"></script>
	</body>
</html>
JS

Code: Select all

(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

Code: Select all

function convertTypeID (typeArray)
{
	return typeIDToStringID(Number(typeArray));
};
Thank you in advance!!!

Re: How my CEP extension can listen to [Select] event but only for [historyState]?

Posted: Mon Nov 11, 2019 8:47 am
by Simonetos The Greek
Hello... Is this forum working anymore???

Re: How my CEP extension can listen to [Select] event but only for [historyState]?

Posted: Tue Nov 12, 2019 5:12 pm
by Kukurykus
The best times for this forum unfortunatelly have passed :(

Re: How my CEP extension can listen to [Select] event but only for [historyState]?

Posted: Wed Nov 13, 2019 6:46 am
by txuku
Bonjour

exactly! :oops:

But this forum is not oriented to the htlm rather the jsx.

Re: How my CEP extension can listen to [Select] event but only for [historyState]?

Posted: Sat Nov 16, 2019 8:18 pm
by Jason407
Can you just check the current history state, and then check to see if it has changed?

This may be helpful:
viewtopic.php?f=68&t=12838&p=78124&hili ... ate#p78124