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: Tom, Kukurykus

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

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

Post 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!!!
User avatar
Simonetos The Greek
Posts: 3
Joined: Tue Jul 02, 2019 8:59 am
Location: Athens, Greece

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

Post by Simonetos The Greek »

Hello... Is this forum working anymore???
User avatar
Kukurykus
Posts: 528
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 »

The best times for this forum unfortunatelly have passed :(
User avatar
txuku
Posts: 136
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 »

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 »

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