Skip to main content
Inspiring
December 3, 2021
Question

List double click function

  • December 3, 2021
  • 3 replies
  • 511 views

the following script not working, i know i have added palette instead of dialog. Kindly help to me

 

var w = new Window ("palette");
var list = w.add ("listbox", undefined, ["one", "two", "three"]);
list.selection = 0;
list.onDoubleClick = function () {

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
app.findTextPreferences =app.changeTextPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = this.selection.text;
var res = app.activeDocument.findGrep();
alert(res.length)

//~ $.writeln (this.selection.text + " double-clicked.")
}
w.show ();

This topic has been closed for replies.

3 replies

Peter Kahrel
Community Expert
Community Expert
February 13, 2022

Srikant -- Actually, when I try your code, it works fine with onDoubleClick.

If it doesn't, at your end, you can try 

list.onChange = function () {
  . . .
}

which in fact is more convenient because the function is triggered by a single click. Quicker, and less risk of repetitive-click syndrome.

 

P.

rob day
Community Expert
Community Expert
December 3, 2021

It might be easier with InDesign’s dialog’s dropdown, something like this:

 

var sel = app.documents[0].selection[0].contents;
makeDialog();

var numDrop; 
function makeDialog(){
    var d = app.dialogs.add({name:"Choose an Item", canCancel:true});
    with(d.dialogColumns.add()){
        var nList = ["One", "Two", "Three"];
        numDrop = dropdowns.add({stringList:nList, selectedIndex:0, minWidth:80});
    }
    if(d.show() == true){
        numDrop = nList[numDrop.selectedIndex];
        runGrep();
        d.destroy();
	}
}

function runGrep(){
    alert(sel + numDrop)
}

 

 

 

Peter Kahrel
Community Expert
Community Expert
December 3, 2021

This stopped working a few years ago. Adobe lost interest and it was never fixed. It probably won't be. There are some bugs against this (see https://indesign.uservoice.com), you can add your voice -- but don't get your hopes high.

Sunil Yadav
Legend
February 12, 2022

That is very sad. Adobe has even stopped working on XML which supported by InDesign a long way before. That hurts.

Sunil Yadav
Legend
February 12, 2022

On top of it they really have to focus on Math ML xml.