Results 1 to 15 of 15
  1.    #1  
    I'm trying to make a reset button that will clear all the fields (figured that one out) then return the focus to the first of three textfields.

    Currently I can get it clear the fields, but after I do that the textfields will no longer accept input. What do I need to do to re-activate them?

    Thanks
  2. #2  
    this.controller.get('textFieldWidgetId').mojo.focus();
  3. #3  
    Not working for me:

    this.taskModel.taskfield = '';
    this.controller.modelChanged(this.taskModel);
    Mojo.Log.info("Okay");
    Mojo.Log.logProperties(this.controller.get("TaskInputId"), 'textfield', false);
    this.controller.get("TaskInputId").mojo.focus();
    Mojo.Log.info("Okay");

    Logs both Okays, but focus does not go to the text field with id=TaskInputID. The logProperties is showing that I'm getting the correct widget. Just not setting the focus.
  4.    #4  
    tried focus() with no results.

    Pre101 on irc said to try event.stopPropagation(); because it's a response to a user tap

    Which did allow me to continue to edit text, but didn't clear the textbox values. What am I doing wrong?

    event.stopPropagation();
    this.controller.get(textfield1).update('');
    this.controller.get(textfield1).focus();
  5. #5  
    By the way, the above code does work for me in clearing the textfield.

    i.e. set the model value to "" and then call modelChanged.

    The textfield is cleared and I can enter new text. But the textfield does not get the focus.
  6.    #6  
    It still doesn't work for me. It will clear the fields but wont let me enter new text and doesn't get focus.
  7. #7  
    I have a similar problem.

    I have a textfield which shows as a white box with flashing cursor when I enter the scene. If I tap anywhere outside that textfield, the white box disappears. If I update the value associated with the textfield programatically the value is displayed where the textfield should be. (No white box. It just looks like a label.) If I tap where the field is the textfield gets focus and the white box reappears. Is there anyway of having the white box shown permanently like an html form <input> field.
  8. #8  
    I had this problem a few months ago. Here's how I fixed it:

    NEVER use ".update('')" to update a textfield. This will render it un-editable (as you've all discovered).

    Instead, use ".mojo.setValue('')" to update textfields. This will clear the textfield and still allow the user to edit it.

    So you're code will look like:
    Code:
    event.stopPropagation(); 
    this.controller.get(textfield1).mojo.setValue('');
    this.controller.get(textfield1).focus();
    Hope that helped. Let me know if it didn't.
  9. #9  
    Sorry johncc, I didn't see you're last post.
    I think this article by Palm should help you out:

    Text Fields-Palm


    The code looks something like this:
    Code:
    //remember to clean up a document listener in your scene assistant's cleanup function!!!!
    this.sceneTapped = this.sceneTapped.bind(this);
    this.controller.listen(this.controller.document, Mojo.Event.tap, this.sceneTapped);
    this.textFieldWidget = this.controller.get('textfield');
    
    sceneTapped: function(tapEvent) {
         //if something that is not the textfield widget or a child of the textfield widget got the tap, call prevent default to
         //stop the textfield widget from blurring
         if (tapEvent.target !== this.textFieldWidget && !tapEvent.target.up('div#'+this.textFieldWidget.id)) {
              tapEvent.preventDefault();
         }
    }
    But you should still check out that article.
    hit up that thanks button
  10. #10  
    sorry to post in this very old thread... but... how did the problem get solved???

    I'm having the same issue... almost....

    I have a textfield and I use buttons to write in it... the problem is when the text is more than the textfield width the text appears as "texttttttt..." (the last 3 dots)

    so i was thinking in returning the focus to the textfield (also this helps if I switch to keyboard input)

    event.stopPropagation();
    this.controller.get(textfield1).mojo.setValue('');
    this.controller.get(textfield1).focus();

    or

    event.stopPropagation();
    this.controller.get(textfield1).mojo.setValue('');
    this.controller.get(textfield1).mojo.focus();

    don't work.... (supossing my textfield is named textfield1)

    so... how did this problem was solved??

    Thanks!!
  11. #11  
    Code:
    someFunc(event){
    
    event.stopPropagation(event);
    this.controller.get('textfield1').mojo.setValue('');
    this.controller.get('textfield1').mojo.focus;
    Works in my existing apps.
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  12. #12  
    mmm... then this is odd....

    my function was

    Code:
    myButton1: function(event, inSender) {
         event.stopPropagation(event);
         this.controller.get('textfield1').mojo.setValue('');
         this.controller.get('textfield1').mojo.focus;
         }
    }
    but it never worked... my text field didn't get the focus at the end... so I used this one

    Code:
    sceneTapped: function(tapEvent) {
         if (tapEvent.target !== this.myTF) {
              tapEvent.preventDefault();
              this.myTF.mojo.focus();
         }
    }
    
    myButton1: function(event, inSender) {
         this.controller.get('textfield1').mojo.setValue('');
         }
    }
    now the focus() function works
  13. #13  
    Another way to update a text field (or the value of any widget) is to use the modelChanged() function. Suppose you have the following widget in your setup function:

    Code:
    var nameAttributes =
    {
            hintText: 'Name...',
        enterSubmits: false,
         limitResize: true,
           multiline: false
    };
    
    this.nameModel = {value: ''};
    this.controller.setupWidget('name', nameAttributes, this.nameModel);
    You can change the value with the following code:

    Code:
    this.nameModel.value = 'What ever you want!';
    this.controller.modelChanged(this.nameModel, this);
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  14. #14  
    Quote Originally Posted by figus View Post
    mmm... then this is odd....

    my function was

    Code:
    myButton1: function(event, inSender) {
         event.stopPropagation(event);
         this.controller.get('textfield1').mojo.setValue('');
         this.controller.get('textfield1').mojo.focus;
         }
    }
    but it never worked... my text field didn't get the focus at the end... so I used this one

    Code:
    sceneTapped: function(tapEvent) {
         if (tapEvent.target !== this.myTF) {
              tapEvent.preventDefault();
              this.myTF.mojo.focus();
         }
    }
    
    myButton1: function(event, inSender) {
         this.controller.get('textfield1').mojo.setValue('');
         }
    }
    now the focus() function works

    The second one you're using actually prevents anything else fom getting the focus, so if you add another textfield ...

    The only difference between your first function and how mine work is that I stop the event propagation, then set the focus to my textfield, then I set the value of it (and I use the modelChanged method to do it like Laxadaisicl posted).

    Was the first one clearing your textfield?
    If so, try putting the focus before the steValue function, if you wanted to.
    WOG Dev - WebOS Group http://www.WebOSGroup.com
    PMP Dev - http://www.PimpMyPre.com
    Apps: WOG O.S.K., WOG Card Keeper, WOG Glowstick, WOG Kid Protect, PreLoad, PimpMySounds
  15. #15  
    Sorry to bump this, but I have tried all of these methods and nothing is working for me.

    I have

    <div class="messStyl" x-mojo-element="RichTextEdit"></div>

    and

    this.controller.setupWidget('message');
    this.controller.listen("message", Mojo.Event.tap, this.messageFocus.bind(this));

    and then

    SecondAssistant.prototype.messageFocus = function(event){
    event.stopPropagation();
    this.controller.get('message').mojo.focus();
    }


    The field has focus when the scene loads, but if I click on another text field, or anywhere else in the screen, it disables the main textfield "message".

Posting Permissions