Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    get value from askForValue

    This is a total newbie question, but I searched around for a while, but was unable to find an answer to this, so any help would be fantastic.I have this piece of code here:
    Code:
    SC.askforValue("textFieldTitle", "Please enter a title for your textField",
          new ValueCallback(){
          @Override
          public void execute(String value) {
                  SC.say("The title you entered is"+value);
    }
                			});
                		}
    All I want to do is get the value that the user inputs into the box and put it into a string the rest of my code can access. How would i get that value?

    #2
    You can store the user-entered value in a member of the class.

    Code:
            final IButton prompt = new IButton("Ask for Value");
            prompt.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    SC.askforValue("What?", "Please enter a value.", new ValueCallback() {
                        @Override
                        public void execute(String value) {
                            // userResponse is declared as a private member of the class
                            userResponse = value;
                        }
                    });
                }
            });
            layout.addMember(prompt);
            
            final IButton say = new IButton("Say");
            say.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    SC.say("You entered: " + userResponse);
                }
            });
            layout.addMember(say);

    Comment


      #3
      Thank you that was very helpful!

      Comment

      Working...
      X