Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
olida
Posts: 11
Registered: ‎11-15-2013
My Device: blackbery 10
Accepted Solution

Textbox

[ Edited ]

 

 

import bb.cascades 1.2

Page {
    Container {
        
        background: Color.create ("#E0E0E0")
			    TextArea {
			     textFormat: TextFormat.Plain
			        inputMode: TextAreaInputMode.Default
			        id:meterId
			        
			
			    }
			    
			}

}

 

 

 I want my textbox to only take numbers, how can I do this? I also want my layout to start from middle of page.That is textbox be in middle of page..and not take 100% of the width.More like 50 %. How can I give a title to the page as well?

Contributor
olida
Posts: 11
Registered: ‎11-15-2013
My Device: blackbery 10

Re: Textbox

I did this, and i only get a number

 

import bb.cascades 1.2

Page {
    Container {
        
        background: Color.create ("#E0E0E0")
			 
        TextField {
            inputMode: TextFieldInputMode.Pin
            autoFit: TextAutoFit.Default
            maximumLength: 5
            textStyle.textAlign: TextAlign.Center

        }

    }

}

 

 

 

however the textfield is coming on top of page, i want it a bit lower. plus i dont want it to take entire width.but half ot and centered

Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Textbox

For the width you can play with
- preferred width and height
- maximum and minimum width and height
And for position I suggest you read Layouts docs
http://developer.blackberry.com/native/documentation/cascades/ui/layouts/


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Contributor
olida
Posts: 11
Registered: ‎11-15-2013
My Device: blackbery 10

Re: Textbox

[ Edited ]
Page {
    Container {
        
        background: Color.create ("#E0E0E0")

        layout: DockLayout {

        }
        TextField {
            inputMode: TextFieldInputMode.Pin
            autoFit: TextAutoFit.Default
            maximumLength: 5
            textStyle.textAlign: TextAlign.Center
            preferredWidth: 205.0
            horizontalAlignment: HorizontalAlignment.Center
            

        }

    }

}

 

Okey if i do that, it gives me width like 205 how can i make the width dynamic?

like screen.width/2 ? and based on resolution?

 

Also i want it to be a bit below the top page. not right at the top.

Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Textbox

You can expose QML property from C++


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Contributor
olida
Posts: 11
Registered: ‎11-15-2013
My Device: blackbery 10

Re: Textbox

and one more question, how can I make input mode just take numbers inputMode: TextFieldInputMode.P

nthg else..
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Textbox

TextInputMode.NumericPassword maybe help 



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Contributor
olida
Posts: 11
Registered: ‎11-15-2013
My Device: blackbery 10

Re: Textbox

yes, but I don't want it to appear as password.
Contributor
olida
Posts: 11
Registered: ‎11-15-2013
My Device: blackbery 10

Re: Textbox

I checked this, done by javascript http://supportforums.blackberry.com/t5/Native-Development/Preventing-non-numeric-key-presses-in-a-Te...

it sthg I hope bb10 improve in it.