Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

UI button programming

Participant ,
May 12, 2018 May 12, 2018

I'm trying to grab a number from the user, default of 1, with buttons next to it that increase or decrease that number

I don't believe I'm even close yet, the number displayed in the UI doesn't change here, also, I'm not sure it's even a number, but text instead.  I'm still very new at this, everything is probably pretty crude.

w = new Window('dialog', "Gadget");

  w.grp1 = w.add('group');

  w.grp1.orientation = "row";

  w.grp1.alignment = "right";

    w.grp1.add("statictext", undefined, "Left Offset:");

    var leftoffset = w.grp1.add("edittext", undefined, 1);

      leftoffset.characters = 3;

      leftoffset.active = true;

    var grp1up = w.grp1.add("button", undefined, "+");

      grp1up.onClick = leftoffset = leftoffset + 1;

    var grp1down = w.grp1.add("button", undefined, "-");

      grp1up.onClick = leftoffset = leftoffset - 1;

Another later goal is to have a checkbox in the UI near the beginning, that allows the button presses to increase the numbers by 0.25's instead of 1's

TOPICS
Scripting
706
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , May 12, 2018 May 12, 2018

Your onClick code has to be revised to be set to a function like this:

grp1up.onClick = function(){

     leftoffset.text = (leftoffset.text * 1) + 1;

}

the * 1 is to turn the string from UI into a number you can calculate with.

Translate
Adobe
Valorous Hero ,
May 12, 2018 May 12, 2018

Your onClick code has to be revised to be set to a function like this:

grp1up.onClick = function(){

     leftoffset.text = (leftoffset.text * 1) + 1;

}

the * 1 is to turn the string from UI into a number you can calculate with.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 12, 2018 May 12, 2018
LATEST

this board hasn't failed me once

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines