×

Discussion Board

Results 1 to 6 of 6

Thread: TEXTBOX

  1. #1
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    118

    TEXTBOX

    hi everyone... i have a textbox with an input size of 160, and if ever the caretposition reaches 80 it will prompt an ALERT message... how do i do this?

    here's my code:
    Code:
    public void Create() //CREATE MESSAGE METHOD
        {
           currentMenu = "Create Message";
           String message = "";
           msg = new TextBox("Create Message", message, 160, TextField.ANY);
           if(msg.getCaretPosition()==80)
           {
      
                    // MUST ALERT HERE... do i need Thread here? 
           }
           msg.addCommand(cancelCommand);
           msg.addCommand(enter_phoneCommand);
           msg.addCommand(clearCommand);
           msg.addCommand(saveCommand);
           msg.setCommandListener(this);
           display.setCurrent(msg);
           resumeScreen = msg;
        }
    i tried supplying it with an Alert but it does nothing...

    please help... thanks

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: TEXTBOX

    You see nothing, because you're calling setCurrent() to display the alert, then setCurrent(msg)... the second one cancels the first. Take a look at the alternative forms of setCurrent(), one of which allows you to set an Alert and another Displayable to show after the Alert.

    Graham.

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: TEXTBOX

    Yeah, you can have the look over this form,
    public void setCurrent(Alert alert,Displayable nextDisplayable)
    Requests that this Alert be made current, and that nextDisplayable be made current after the Alert is dismissed. This call returns immediately regardless of the Alert's timeout value or whether it is a modal alert. The nextDisplayable must not be an Alert, and it must not be null.
    The automatic advance to nextDisplayable occurs only when the Alert's default listener is present on the Alert when it is dismissed
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    118

    Re: TEXTBOX

    oh i see... coz i must be able to display the textbox first... and prompt an alert whenever my caret position reaches 80. can i use thread here? thank you for the reply raj and graham

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: TEXTBOX

    Quote Originally Posted by binsint View Post
    oh i see... coz i must be able to display the textbox first... and prompt an alert whenever my caret position reaches 80. can i use thread here? thank you for the reply raj and graham
    (msg.getCaretPosition()==80) should be in a separate thread, then only it will be able to monitor the textbox Caret Position - while the user is entering the text.
    In your code, if you put a System.out.println(msg.getCaretPosition()) you might get to see a 0.
    As per API doc:
    getCaretPosition

    public int getCaretPosition()
    Gets the current input position. For some UIs this may block and ask the user for the intended caret position, and on other UIs this may simply return the current caret position.
    Returns:
    the current caret position, 0 if at the beginning
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  6. #6
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    118

    Re: TEXTBOX

    (msg.getCaretPosition()==80) should be in a separate thread, then only it will be able to monitor the textbox Caret Position - while the user is entering the text.
    what will be the code if i have a new thread? can you give me a sample code with the same scenario i quoted? im not good at threads.
    thanks im2amit...

Similar Threads

  1. textbox validation
    By devalin85 in forum Mobile Java General
    Replies: 7
    Last Post: 2010-04-09, 13:17
  2. textbox
    By helwg1130 in forum Mobile Java General
    Replies: 9
    Last Post: 2009-07-24, 08:15
  3. textbox
    By palak_shah_23 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-05-29, 12:53
  4. TextBox
    By seregindv in forum Mobile Java General
    Replies: 6
    Last Post: 2005-04-19, 16:35
  5. TextBox example
    By Danack in forum Mobile Java General
    Replies: 2
    Last Post: 2003-10-07, 16:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×