Skip to main content
j.khakase
Inspiring
September 2, 2022
Answered

script code, which will enable value changing by mouse click and scroll

  • September 2, 2022
  • 2 replies
  • 756 views

Hello, need help on 

Looking for Illustrator script code, which will enable value changing by mouse click and scroll in the dialog comes while running the custom script. As we do at x and y position in property

 

 

This topic has been closed for replies.
Correct answer jduncan

I assume you are wanting to be able to adjust the values within an edittext field by scrolling your mouse up and down as you can within native Illustrator palettes (while the text is selected). Unfortunately, I don't think it's possible in ExtendScript. JavaScript does have a "wheel" event (see here) but I can't find any mention of it in the ExtendScript docs.

 

An alternate option is to use the arrow keys to increase/decrease the value. Not exactly what you are looking for but similar. The code below was taken directly from Peter Kahrel's ScriptUI for dummies book page 88.

 

var w = new Window ("dialog");
var e1 = w.add ("edittext", undefined, "1");
var e2 = w.add ("edittext", undefined, "1"); e1.characters = e2.characters = 3; e1.active = true;
function handle_key (key, control) {
var step;
key.shiftKey ? step = 10 : step = 1; switch (key.keyName)
{
case "Up": control.text = String(Number(control.text)+step); break; case "Down": control.text = String(Number(control.text)-step);
}
} // handle_key
e1.addEventListener ("keydown", function (k) {handle_key (k, this);});
e2.addEventListener ("keydown", function (k) {handle_key (k, this);}); w.show();

 

2 replies

jduncan
Community Expert
jduncanCommunity ExpertCorrect answer
Community Expert
September 2, 2022

I assume you are wanting to be able to adjust the values within an edittext field by scrolling your mouse up and down as you can within native Illustrator palettes (while the text is selected). Unfortunately, I don't think it's possible in ExtendScript. JavaScript does have a "wheel" event (see here) but I can't find any mention of it in the ExtendScript docs.

 

An alternate option is to use the arrow keys to increase/decrease the value. Not exactly what you are looking for but similar. The code below was taken directly from Peter Kahrel's ScriptUI for dummies book page 88.

 

var w = new Window ("dialog");
var e1 = w.add ("edittext", undefined, "1");
var e2 = w.add ("edittext", undefined, "1"); e1.characters = e2.characters = 3; e1.active = true;
function handle_key (key, control) {
var step;
key.shiftKey ? step = 10 : step = 1; switch (key.keyName)
{
case "Up": control.text = String(Number(control.text)+step); break; case "Down": control.text = String(Number(control.text)-step);
}
} // handle_key
e1.addEventListener ("keydown", function (k) {handle_key (k, this);});
e2.addEventListener ("keydown", function (k) {handle_key (k, this);}); w.show();

 

j.khakase
j.khakaseAuthor
Inspiring
September 3, 2022

Perfect Answer, if this is not possible through Illustrator script. An alternate option works in my case. So thank you so much @jduncan to suggest the idea to change the value

Participant
September 2, 2022

Sorry but your request doesn't seem clear to me. Would you please provide more explanations?