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

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: xbytor, DavideBarranca, Paul MR

Post Reply
User avatar
Simonetos The Greek
Posts: 3
Joined: Tue Jul 02, 2019 8:59 am

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

Post by Simonetos The Greek » Fri Nov 08, 2019 9:20 am

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!!!

User avatar
Simonetos The Greek
Posts: 3
Joined: Tue Jul 02, 2019 8:59 am

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

Post by Simonetos The Greek » Mon Nov 11, 2019 8:47 am

Hello... Is this forum working anymore???

User avatar
Kukurykus
Posts: 225
Joined: Mon Jul 25, 2016 12:36 pm

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

Post by Kukurykus » Tue Nov 12, 2019 5:12 pm

The best times for this forum unfortunatelly have passed :(

User avatar
txuku
Posts: 75
Joined: Thu Jan 01, 1970 12:00 am

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

Post by txuku » Wed Nov 13, 2019 6:46 am

Bonjour

exactly! :oops:

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

Jason407
Posts: 2
Joined: Thu Sep 19, 2019 12:56 pm

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

Post by Jason407 » Sat Nov 16, 2019 8:18 pm

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

Post Reply