×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    3

    Wrt numeric input mode for textfields

    Hi All

    I'm creating a sms app in WRT that uses the wrtkit.
    The user needs to enter a cellphone number into a textfield to log into the app.

    so on to my question:

    Does anyone know of a way to automatically switch to numeric input mode in a textfield?
    I know that for wap pages you can use the -wap-input-format property in css to set the input mode but I have tried adding an extra control to the wrtkit that has this style but it doesn't work. Probably since wrt uses xhtml instead of wml.

    The code I used is as follows (most of it is a replica of the textfield class)

    Code:
    // Constructor.
    function NumericTextField(id, caption, value, masked) {
        if (id != UI_NO_INIT_ID) {
            this.init(id, caption, value, masked);
        }
    }
    
    // NumericTextField inherits from TextEntryControl.
    NumericTextField.prototype = new TextEntryControl(UI_NO_INIT_ID);
    
    // Initializer - called from constructor.
    NumericTextField.prototype.init = function(id, caption, value, masked) {
        uiLogger.debug("NumericTextField.init(" + id + ", " + caption + ", " + value + ", " + masked + ")");
        
        // call superclass initializer
        TextEntryControl.prototype.init.call(this, id, caption);
        
        // create the peer element
        this.peerElement = document.createElement("input");
        this.peerElement.type = masked ? "password" : "text";
        //this.peerElement.format = "12N";
        this.peerElement.classname = "NumberField";
        //this.peerElement.style = "-wap-input-format:'12N'";
        this.controlElement.appendChild(this.peerElement);
        
        // set the value
        this.peerElement.value = (value == null) ? "" : value;
        
        // bind event listeners
        this.bindTextEntryControlListeners();
        
        // update the style
        this.updateStyleFromState();
    }
    
    // Updates the style of the control to reflects the state of the control.
    NumericTextField.prototype.updateStyleFromState = function() {
        uiLogger.debug("NumericTextField.updateStyleFromState()");
        
        // determine the state name
        var stateName = this.getStyleStateName();
        
        // set element class names
        this.setClassName(this.rootElement, "Control");
        this.setClassName(this.controlElement, "ControlElement");
        this.setClassName(this.assemblyElement, "ControlAssembly ControlAssembly" + stateName);
        this.setClassName(this.captionElement, "ControlCaption ControlCaption" + stateName);
        this.setClassName(this.peerElement, "NumberField");
        
        
        // set peer element class names
        var peerStateName = this.isEnabled() ? stateName : "Disabled";
        this.setClassName(this.peerElement, "NumberField TextField TextField" + peerStateName);
    }
    and the css is:
    Code:
    .NumberField{-wap-input-format: "12N";}

    Any ideas anyone?

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    3

    Re: Wrt numeric input mode for textfields

    Actually the problem was elsewhere. This code works. Hope this helps anyone who has the same issue.

Similar Threads

  1. How to get the phone present Input mode
    By qustsnc in forum Symbian
    Replies: 10
    Last Post: 2010-02-04, 03:34
  2. Default numeric input mode for SECRETED control
    By chandran.biju007 in forum Symbian User Interface
    Replies: 3
    Last Post: 2010-01-26, 14:00
  3. Replies: 3
    Last Post: 2008-12-23, 12:02
  4. Replies: 6
    Last Post: 2008-12-17, 08:23
  5. Defaulting to numeric input mode on 7710
    By asy@hostnest.net in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-06-25, 08:33

Posting Permissions

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