Results 1 to 17 of 17
  1.    #1  
    I have a text box at the bottom of a scene. The problem is that when the scene is started it starts at the bottom with the cursor in the text box. I don't want it to do that. I want it to start at the top of the scene. I have tried setting the 'autoFocus' attribute to false but that doesn't work.

    I can think of a cheap way to do this by disabling the text box at first and then forcing the user to enable it by button press (at least I think that will work... haven't tried it yet), but I was hoping for a more elegant solution. The text is used to input data when you first use the app and after that only if you want to change it. I don't want to put it in another scene as I want it to be easily accessed at any time.

    I am grateful for any help in this matter.
  2. #2  
    Maybe you could use the blur() method. Do you have a textbox at the top of the scene? If so set its autoFocus to true. Or you could use focus() or blur() in the activate function.

    example:
    Code:
    $('element').mojo.focus()
    AmpachPre, your music your way.

  3.    #3  
    Thank you for the help.

    I tried putting the line of code below in the setup function right after I set up the text field:

    $('textField').mojo.blur()

    However, it didn't work. I am not really sure what blur is supposed to do or if I even used it right.
  4. #4  
    What's the code you are using to initialize the textfield Widget?
    mobigamedepot.com
  5. #5  
    Quote Originally Posted by Beherrschen View Post
    Thank you for the help.

    I tried putting the line of code below in the setup function right after I set up the text field:

    $('textField').mojo.blur()

    However, it didn't work. I am not really sure what blur is supposed to do or if I even used it right.
    The blur method just removes the text field from focus
    Javascript Glossary - Blur

    You need to take the 'textField' portion of the example above and replace it with your divs id name.

    edit: oops i just realised that wasn't my initial example. Disregard that last line...
    AmpachPre, your music your way.

  6.    #6  
    This is what I have. Thanks for all the help. I am still learning.

    javascript:
    Code:
    var attributes = {
    			hintText: 'Enter Value',
    			textFieldName:	'name', 
    			modelProperty:		'originalValue', 
    			multiline:		false,
    			disabledProperty: 'disabled',
    			autoFocus:	false, 
    			modifierState: 	Mojo.Widget.numLock,
    			limitResize: 	false, 
    			holdToEnable:  false, 
    			focusMode:		Mojo.Widget.focusSelectMode,
    			changeOnKeyPress: true,
    			maxLength: 30,
    			requiresEnterKey: false
    		};
    		this.models = {
    			originalValue : '',
    			disabled: false
    		};
    		this.controller.setupWidget('textField', attributes, this.models);
    	
    	//blur textfield
    	$('weight').mojo.blur()
    HTML:
    Code:
     <div class="palm-group">
        <div class="palm-group-title" id="weight" style="text-align: center">Value</div>
    	<div class="palm-list">
       		<div class="palm-row single">
    			<div class="palm-row-wrapper textfield-group" x-mojo-focus-highlight="true">
    				<div class="title">
          				<div id="textField" name="textField"  x-mojo-element="TextField"></div>
    				</div>
    			</div>
    		</div>
    	</div>
    </div>
  7. #7  
    This is very similar to a problem I was having and was never able to solve it. It's possible that there is no solution. You might try posting on the "bugs and new features" on the Palm dev forum:
    Forums webOS &bull; View forum - Bug Reports and Feature Requests
    mobigamedepot.com
  8.    #8  
    Quote Originally Posted by djpushplay View Post
    This is very similar to a problem I was having and was never able to solve it. It's possible that there is no solution. You might try posting on the "bugs and new features" on the Palm dev forum:
    Forums webOS &bull; View forum - Bug Reports and Feature Requests
    I would go ahead and call it a bug if I could get the app to run past the blur method line... it seems like that is what I want but everytime I run the app it stops at that line of code.

    Code:
     $('weight').mojo.blur()
  9. #9  
    I noticed that there seems to be no ".mojo" property for the widgets in the setup method. Later on, no problem, but during the setup it's null and thus, causes some hard-to-debug errors.

    It worked for me to put all that stuff into a single function to be called via setTimeout, e.g.:

    Code:
    var txt = this.controller.get("textField");
    setTimeout(function() { if (txt.mojo) { txt.mojo.blur(); } }, 100);
    Maybe it would work in the activate method as well?
  10. #10  
    Quote Originally Posted by Beherrschen View Post
    I would go ahead and call it a bug if I could get the app to run past the blur method line... it seems like that is what I want but everytime I run the app it stops at that line of code.

    Code:
     $('weight').mojo.blur()
    you want to blur the actual widget which in your case its id is 'textField'
    Code:
    <div id="textField" name="textField"  x-mojo-element="TextField"></div>
    so it would be
    Code:
    $('textField').mojo.blur()
    AmpachPre, your music your way.

  11. #11  
    Quote Originally Posted by xschemer View Post
    I noticed that there seems to be no ".mojo" property for the widgets in the setup method. Later on, no problem, but during the setup it's null and thus, causes some hard-to-debug errors.

    It worked for me to put all that stuff into a single function to be called via setTimeout, e.g.:

    Code:
    var txt = this.controller.get("textField");
    setTimeout(function() { if (txt.mojo) { txt.mojo.blur(); } }, 100);
    Maybe it would work in the activate method as well?
    Nope doesn't work in the activate mode, I just tried it. Maybe you could hide the text field and when they begin to type it will appear with the show and hide methods. the timeout function xschemer suggested should work as well.
    AmpachPre, your music your way.

  12.    #12  
    Quote Originally Posted by xschemer View Post
    I noticed that there seems to be no ".mojo" property for the widgets in the setup method. Later on, no problem, but during the setup it's null and thus, causes some hard-to-debug errors.

    It worked for me to put all that stuff into a single function to be called via setTimeout, e.g.:

    Code:
    var txt = this.controller.get("textField");
    setTimeout(function() { if (txt.mojo) { txt.mojo.blur(); } }, 100);
    Maybe it would work in the activate method as well?
    ok... where exactly should I put those lines of code. I tried them in the setup but that didn't work (the app ran but didn't blur). I am a little unsure if that is what you were telling me to do.
  13. #13  
    It should work inside the setup method. (I just tried it.) Make sure the textfield ID is right (like fain mentioned).

    Btw, even if this blurs the textfield, the scene might still scroll down (since the field isn't blurred for a short period of time). So, perhaps you should use this somewhere (Dunno if I remember it right but I think that even worked in the setup method?):
    Code:
    this.controller.getSceneScroller().mojo.scrollTo(0, 0);
  14.    #14  
    Quote Originally Posted by xschemer View Post
    It should work inside the setup method. (I just tried it.) Make sure the textfield ID is right (like fain mentioned).

    Btw, even if this blurs the textfield, the scene might still scroll down (since the field isn't blurred for a short period of time). So, perhaps you should use this somewhere (Dunno if I remember it right but I think that even worked in the setup method?):
    Code:
    this.controller.getSceneScroller().mojo.scrollTo(0, 0);
    No luck... it is blurred but still starts the scene at the bottom. I even tried the above code but no change.

    I tried using the following...

    Code:
     Mojo.Controller.SceneController.setInitialFocusedElement(focusedElement)
    but no luck still. Ugh... I can't release this update (which I feel my app needs soon) until I get a solution. I really don't want to put it in a separate scene... but I may have to do it until a solution comes around... but I really don't want to lol.
  15. #15  
    And if you put it into the setTimeout'd function, too? Could look like this:
    Code:
    var txt = this.controller.get("textField");
    var me = this;
    setTimeout(function() { 
        if (txt.mojo) { txt.mojo.blur(); } 
        me.controller.getSceneScroller().mojo.scrollTo(0, 0);
    }, 100);
  16.    #16  
    Quote Originally Posted by xschemer View Post
    And if you put it into the setTimeout'd function, too? Could look like this:
    Code:
    var txt = this.controller.get("textField");
    var me = this;
    setTimeout(function() { 
        if (txt.mojo) { txt.mojo.blur(); } 
        me.controller.getSceneScroller().mojo.scrollTo(0, 0);
    }, 100);
    I had tried that but it didn't work... however since you reaffirmed the idea I tried it by increasing the 100 to 1000 and it worked... but you could see the switch back to the top. So I tried some other numbers and 500 seems to be the sweet spot.

    THANK YOU ALL FOR THE HELP!! YOU ROCK!!
  17. krid's Avatar
    Posts
    117 Posts
    Global Posts
    135 Global Posts
    #17  
    I went thru the same thing, and found that this does the job:

    me.controller.setInitialFocusedElement(null);
    Author of Keyring for webOS - Easy password management on your phone

    Get Keyring :: Keyring website :: Keyring desktop client :: Keyring bugs :: Desktop client bugs

    Like what I've done with Keyring? Hire me!

Posting Permissions