Forum Replies Created

Page 23 of 32
  • Xavier Gomez

    August 29, 2013 at 2:53 pm in reply to: “Are you sure?”-box problem

    There is a built-in global function that does this: confirm (message[,noAsDflt,title]); displays a modal window with one question and 2 buttons “Yes” “No”. So unless you want some particular window design it is easier to use confirm.

    message is the message to display, title is the windows title, and noAsDflt sets the default button (the one that is hit if you press enter instead of clicking a button). The default button is normally “YES”, unless you set ‘noAsDflt’ to true.

    if (confirm("Are you sure ?", true, "Please confirm")) doThis()
    else doThat();

    Xavier

  • Xavier Gomez

    August 23, 2013 at 9:50 pm in reply to: Add button and textfield to UI

    It is ‘less than’ 😉
    Change it to the math sign.

  • Xavier Gomez

    August 23, 2013 at 9:09 am in reply to: Add button and textfield to UI

    For the above code, unless i miss something, it is normal that nothing shows up since the checkbox status “false” is just an empty space.

    To know if a group contains a listbox, since you are the one writing the script you can add to it the property “hasListbox”, set to true, and for the other groups do nothing. Then “if (something.hasListbox)” will tell you what you want. Not very constructive but it is simple and the fastest you can get. Otherwise, to know if ‘something’ is a listbox do “if something instanceof ListBox”. For instance to check if a group has a listbox in its immediate children it could be like this:
    var hasListbox, K=theGroup.children.length, k;
    for (k=0; k lt K; k++) if (theGroup.children[k] instanceof ListBox) {hasListbox = true; break;}

    For a recursive search in eventual subgroups,
    function search(cont, what)
    {
    if (cont instanceof what) return true;
    if (cont.children) for (var K=cont.children.length, k=0; k lt K; k++) if (search(cont.children[k], what)) return true;
    return false;
    }

    >> search(myGroup, ListBox);

    Xavier

  • Xavier Gomez

    August 22, 2013 at 3:57 pm in reply to: Add button and textfield to UI

    You need to decide if you absolutely need multiline text.

    If so, abandon the listbox, replace it by a group (orientation column) and instead of add/remove listbox items you add/remove groups (orientation row), each consisting of 1 checkbox and 1 multiline edittext. Pretty much the same thing but you loose the nice listbox properties.

    Otherwise, i would showHeaders, with 2 columns, one for short title, the other for full “to do” descriptions. You get the column extendability which is quite useful.

  • Xavier Gomez

    August 22, 2013 at 3:01 pm in reply to: Add button and textfield to UI

    “I would like the text to continue in a new row”

    Ok so i had misread your question. It looks more natural on a new row than on a new column… But then i don’t know and i’m wondering if i lead you to a wrong direction with listboxes. I’m already curious how you could manage to get an item over two rows. What’s your secret ?!

    Xavier

  • Xavier Gomez

    August 22, 2013 at 1:32 pm in reply to: Add button and textfield to UI

    listboxes have quite a few creation properties, especially multicolumn ones. Jeff Almasol posted a template in this thread: https://forums.adobe.com/message/2539586#2539586
    If you set showHeaders to true, the columns become extendable and you dont need to split text through different columns.

    If you absolutely want to split the text over several columns, it is hard because there is no way to know what will be the effective width (in pixels) of the text. You can try splitting by a fixed amount of characters, like this:
    var str = (the whole text);
    var chunks=[], n=0, maxChars=30;
    while (n lt str.length) {chunks.push(str.slice(n, n+maxChars)); n+=maxChars;}
    but it will probably turn out very uggly.

    Xavier

  • Xavier Gomez

    August 22, 2013 at 11:21 am in reply to: Add button and textfield to UI

    🙂
    Anyone discovering this PDF enters a similar state of excitement. It is such a relief after days/weeks/months/years(?) of frustration and dispear!!! Same as you, i wished i had found it sooner.

    I forgot to mention David Torno’s video series: https://forums.adobe.com/thread/1273510?tstart=0 that has 2 episodes on ScriptUI (11 & 12). It is not as complete as the PDF guide (not the same goal) but very useful when one starts from scratch.

    Xavier.

  • Xavier Gomez

    August 22, 2013 at 8:41 am in reply to: Add button and textfield to UI

    You dont need to add special checked icons to items, unless you absolutely want to. Items in a listbox have a built-in checked/unchecked status: item.checked = true/false. It does indent the item text so if you plan to use it it is better to create all items with checked status set to something (not undefined).

    By the way i’m borrowing all this from scriptui-2-0 by Peter Kahrel. If you are not aware of it, it is a great PDF guide to ScriptUI. Link : https://www.kahrel.plus.com/indesign/scriptui.html

    Also, you shoulnt redefine onClick since it is a built-in ListBox event (select item). And so is Ctrl+Click (deselect item). I just tried this and it works in AECS5.5, but not in ESTK:
    listbox.onClick = function()
    {
    if (ScriptUI.environment.keyboardState.shiftKey && this.selection) this.selection.checked ^=1;
    }

    It checks/unchecks the item using Shift+Click.

    Xavier

  • Xavier Gomez

    August 21, 2013 at 7:48 pm in reply to: Add button and textfield to UI

    For the doubleclick i lied a bit… items cannot carry eventListeners, only the listbox can. But it still can work if your listbox doesnt have properties.multiselect set to true. For instance

    listbox.onDoubleClick = function()
    {
    var sel = this.selection, subItems = sel.subItems, K = subItems.length, k;
    var v = [sel.text]; for (k=0; k lt K; k++) v.push(sel.subItems[k].text);
    alert(v.toSource());
    }

    Then instead of an alert you can create/show a small window with v.length EditTexts and modify the selected item with that.

    Xavier.

  • Xavier Gomez

    August 21, 2013 at 11:17 am in reply to: Add button and textfield to UI

    Create a Group or Panel in your UI for all your “things to do” and use add()/remove() methods.

    Or create a ListBox and use its add()/remove() methods: even simpler, and better since it will be automatically scrollable, items can be selected, clicked, double-clicked, there can be as many rows/columns as you want etc.

Page 23 of 32

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy