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
ThomasD
Posts: 26
Registered: ‎01-04-2013
My Device: Playbook

Two Questions Really - Numbers Only in TextField and Conditionals for Calculation

Hello,

 

I have a couple of questions - well a couple of areas I am really having difficulty with.  I am currently trying to develop the entire application in QML with some javascript.  I could use C++, but for lack of time right now, just trying to hash it out in this format.

 

At present I have three Textfields on a page that will be populated with Numbers.  I am currently using the Pin keyboard.  I have a javascript that will remove non numer characters if I use the onSubmitted Signal, however will not work with onTextChanging or onTextChanged.  I am assuming this has to do with the fact that to make a call siilar to

 

text = rootContainer.javascript(text)

 

probably will not work as text is in the process of being defined - for onTextChanging anyways.  Not sure why this is happening for onTextChanged though. 

 

Is there a way to do this other than onSubmitted or adding a label to show what is entered.  Can you overlay a label on a textfield and then only have it visible?

 

Part two - my other issue deals with calling the calculate function only when i have text in each of the three textFields.  Can I have a conditional where defined for each text variable inside the onSubmitted, onTextChang(ing/ed) signals that will call the function only when I have values for each.

 

Any help would be very much appreciated.

D

Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Two Questions Really - Numbers Only in TextField and Conditionals for Calculation

[ Edited ]

This thread might help:

http://supportforums.blackberry.com/t5/Cascades-Development/Preventing-non-numeric-key-presses-in-a-...

 

As for the second question, you can use properties:

SomeClass {
    id: someName
    ...
}
 
...in handler...
 
someName.someProperty = someValue

...in other handler...

if (someName.someProperty == someValue)
{   ...   }

 


Andrey Fidrya, @zmeyc on twitter
Contributor
ThomasD
Posts: 26
Registered: ‎01-04-2013
My Device: Playbook

Re: Two Questions Really - Numbers Only in TextField and Conditionals for Calculation

Have checked through that thread already.  They are basicall running into the same issue.  However the solution presented calls the javascript setting a the Text from another Label or TextField to the output of the script.

 

Thanks though.