It could be really useful to be able to monitor the position of the mouse on top of canvas in Photoshop.
As a minimal proposal, it should be possible to get the value of the mouse on top of canvas in percents.
I.e. something like:
getMousePos() returns [0.5, 0.5] when the mouse is in the center of the image.
It could be also useful to get an RGB value of the pixel, where the mouse is currently on. It could be a bit tricky, RGB value could be calculated for all values or for values of the current layer or below (or even values of the layer below current).
No, it solved just half of the problem. Reading color at some coordinates But maybe count tool could be misused as it generates a lot of events as you drag it
@Jarda Disclaimer could be issued in docs. We already have something similar with “Don’t subscribe to all possible events, please”. And I am pretty sure nobody would use a laggy panel, so panel developers could implement their code based on best practices.
If we use subscription on events - it could only make issues when subscribed.
And still it is kinda does not make issues, because my prototype works with legacy extensions and a mouse listener though a C++ library. But now we are a sandbox in UXP, so not an option to implement.
That is why I was thinking on polling it - much easier to implement, not soo resource intensive, if you poll it 5 times a second (and you only poll it if a panel is open anyway).
Such functionality is used for example in the Curves panel, it shows a vertical line for a hovered pixel. Which is super useful for stuff like custom spectrograms/histograms/custom color pickers.
There could be some performance issues to be added by this into core base of Photoshop, but I think the code is already there, just not exposed to UXP (i.e. native panels use it all around).
In the perfect world, would be nice to have a mechanism to program hand adjustment tool from the curve panel (i.e. you can handle custom tools). But that would never happen, because it is a lot of functionality
Oh, and tracking mouse outside of a panel, especially for dragging events is useful too (at least it is how all panels in all software handle drag, they just don’t stop receiving drag events, when mouse is not under the panel).
Accessing mouse position outside of a panel is useful for people who are making dragging elements work the same as for the native panels (I.e. keep dragging when not over the panel). But it is more of an usability feature.
sob., 22 lip 2023, 12:07 użytkownik Michael Uvarov <freeakk@gmail.com> napisał:
Sorry to interfere,
I may have mist something but it looks like no solution was found.
I get color & position with the “ColorSamplerTool” and the following code
//##################################################
var listener = (e, d) => {
myEvent = e
myData = d
if (myEvent == "make") {
var target = myData._target[0]._ref
if(target == "colorSampler")
{
executeAsModal( async () => {
await getData()
await printPoint()
})
}
}
}
//##################################################
require("photoshop").action.addNotificationListener(
[
{ event: "make" },//this should work
],
listener
)
//##################################################
const getData = async () => {
await executeAsModal(() => {
const cs = app.activeDocument.colorSamplers[0]; // 0 for first, 1 for second
const { color, position } = cs; // destructuring assignment
doc = app.activeDocument
w = doc.width
h = doc.height
positionX = Number(position.x)/w*100;
positionY = Number(position.y)/h*100;
myRed = Math.round(color.rgb.red)
myGreen = Math.round(color.rgb.green)
myBlue = Math.round(color.rgb.blue)
console.log("Red",myRed,"Green",myGreen,"Blue",myBlue)
console.log("X",position.x,"Y", position.y);
console.log("Point X in percent",positionX)
console.log("Point Y in percent",positionY)
app.activeDocument.colorSamplers.removeAll();
})
}
Thanks for your opinion. I agree but it was what I needed for my project.
I posted it knowing that the trigger could be changed to get the results required
If we could somehow access this information, it would be perfect.
I don’t see anything related on the public API, but perhaps it’s possible via batchPlay calls?
Yeah, internally PS knows it and built-in panels use it (i.e. info and curves panels).
Probably we would have to wait till Adobe team would start using the info for their javascript panels.