经过多次尝试,我设法创建一个工作的自定义进度条,即使用OnDraw命令定制它,它也会 Flink (我仍然不明白为什么,也许是用update命令连续重绘)。
我想添加一个按钮,将停止进度条(然后也脚本),也许添加一个警告消息,但我遇到了一个问题。
无论是在进度条前进时还是在正常的调色板上,按钮似乎对单击都没有响应。
在对话框中它可以工作,在调色板和窗口中它不能。
我怀疑这是因为,在photoshop中要保持调色板处于打开状态,它必须处于忙状态,否则它就会关闭,这导致我无法按下按钮。
我试了所有能想到的方法,但都没用。
有办法实现这个吗?
下面是我的代码示例:
progressbar (100);
for ( var e = 0; e < 100; e++ ) {
progressbar.progress ();
}
progressbar.close ();
function progressbar (total) {
var win = new Window ("palette", undefined, undefined, {closeButton: false, borderless: true});
win.orientation = "row";
var barheight = 15;
var halfbarheight = barheight / 2;
var barwidth = 500;
var bar = win.add ("progressbar", [0, 0, barwidth, barheight], 0, total);
bar.onDraw = function () {
with (bar) {
graphics.drawOSControl ();
graphics.newPath ();
graphics.moveTo (halfbarheight, 0);
for (var a = 0; a < Math.PI; a += Math.PI / 100) {
graphics.lineTo ((-halfbarheight * Math.sin (a)) + halfbarheight, (-halfbarheight * Math.cos (a)) + halfbarheight);
}
graphics.lineTo (halfbarheight + (bar.value * ((barwidth - barheight) / total)), barheight);
for (var b = 0; b < Math.PI; b += Math.PI / 100) {
graphics.lineTo ((halfbarheight * Math.sin (b)) + halfbarheight + (bar.value * ((barwidth - barheight) / total)), (halfbarheight * Math.cos (b)) + halfbarheight);
}
graphics.lineTo (halfbarheight, 0);
graphics.closePath ();
graphics.fillPath (graphics.newBrush (graphics.BrushType.SOLID_COLOR, [0.25, 0.83, 0.1]));
}
}
var close = win.add ("iconbutton", [0, 0, 15, 15]);
close.onDraw = function (event) {
with (close) {
graphics.drawOSControl ();
graphics.ellipsePath (0, 0, size[0], size[1]);
graphics.fillPath (graphics.newBrush (graphics.BrushType.SOLID_COLOR, [0.6, 0, 0]));
if (event.mouseOver) {
graphics.fillPath (graphics.newBrush (graphics.BrushType.SOLID_COLOR, [0.85, 0, 0]));
}
}
}
close.onClick = function () {
progressbar.close ();
return;
}
progressbar.close = function () {
win.close ();
}
progressbar.progress = function () {
bar.value++;
$.sleep (100);
win.update ();
}
win.show ();
}
1条答案
按热度按时间wztqucjr1#
如果这是任何帮助,工程完美的PS CS6,Mac os。和它的美丽!