Text Boxes formatting text
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 6
- Joined: Mon Apr 30, 2018 9:22 pm
Text Boxes formatting text
Hi,
I am evaluating LiveCode at the moment. Maybe I am missing something, but it seems like a lot of hard work if your application has a lot of numeric fields / fields that need to be upper case. I think this would be true of a lot of business applications.
As far as i can see he only way is to put code onto each field. Having coded once I can't see a way of saving these as a template, so each time you need to copy & paste the code. Guess you can put one of each type on the main stack, make them invisible and copy from there onto the other stacks.
Have I missed something, is there a better way of doing this?
Thanks.
Richard
I am evaluating LiveCode at the moment. Maybe I am missing something, but it seems like a lot of hard work if your application has a lot of numeric fields / fields that need to be upper case. I think this would be true of a lot of business applications.
As far as i can see he only way is to put code onto each field. Having coded once I can't see a way of saving these as a template, so each time you need to copy & paste the code. Guess you can put one of each type on the main stack, make them invisible and copy from there onto the other stacks.
Have I missed something, is there a better way of doing this?
Thanks.
Richard
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Text Boxes formatting text
Hi.
It is simple and straightforward to place Title Text, or any other variant into a field. Further, user input can be reformatted live.
As for numeric input, again, that can be filtered live to ensure that only digits are allowed (or not allowed) as required. Validation of entered text is well established.
Further, it is probable that a single handler, placed in the message hierarchy "above" the fields on a card, or in a stack, can manage all of them.
Can you give an example of what you are trying to achieve, in plain english, so we can offer solutions? I promise that what we send back will make you smile.
Craig Newman
It is simple and straightforward to place Title Text, or any other variant into a field. Further, user input can be reformatted live.
As for numeric input, again, that can be filtered live to ensure that only digits are allowed (or not allowed) as required. Validation of entered text is well established.
Further, it is probable that a single handler, placed in the message hierarchy "above" the fields on a card, or in a stack, can manage all of them.
Can you give an example of what you are trying to achieve, in plain english, so we can offer solutions? I promise that what we send back will make you smile.
Craig Newman
-
- Posts: 6
- Joined: Mon Apr 30, 2018 9:22 pm
Re: Text Boxes formatting text
Hi,
For a numeric text box I want to be able to: -
1. set the number of decimal places
2. use the comma as a thousands separator
3. include a currency symbol, set a different background colour to the text box if the currency being used is different to the home currency.
4. If the number in the text box is zero display nothing rather than a zero.
the format of the text box needs to be set for the displaying and editing of data.
Thanks
Richard
For a numeric text box I want to be able to: -
1. set the number of decimal places
2. use the comma as a thousands separator
3. include a currency symbol, set a different background colour to the text box if the currency being used is different to the home currency.
4. If the number in the text box is zero display nothing rather than a zero.
the format of the text box needs to be set for the displaying and editing of data.
Thanks
Richard
Re: Text Boxes formatting text
Hi Richard,
welcome to the forum!
You can write re-usable code in LC with behaviours.
Simple example:
1. Create a button with this script, you can hide the button afterwards:
2. Now create a field and set its behavior to that button (Inspector for the field)
Et voila, that field will only accept numbers as imput.
This way you can attach this single script object to as many fields as you like.
Get the picture?
Best
Klaus
welcome to the forum!
You can write re-usable code in LC with behaviours.
Simple example:
1. Create a button with this script, you can hide the button afterwards:
Code: Select all
on keydown tKey
if tKey is in "0123456789" then
pass keydown
end if
end keydown
Et voila, that field will only accept numbers as imput.
This way you can attach this single script object to as many fields as you like.
Get the picture?
Best
Klaus
-
- Posts: 6
- Joined: Mon Apr 30, 2018 9:22 pm
Re: Text Boxes formatting text
Hi Kurt,
Thanks for the welcome
OK that makes sense, thanks for the help.
Will try and work the rest out
Richard
Thanks for the welcome
OK that makes sense, thanks for the help.
Will try and work the rest out
Richard
Re: Text Boxes formatting text
OH, COME ON!
Re: Text Boxes formatting text
Klaus, you must have the single most mangle-able name on the net
-
- Posts: 6
- Joined: Mon Apr 30, 2018 9:22 pm
Re: Text Boxes formatting text
sorry
Richard
Richard
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Text Boxes formatting text
Behaviors is also a good way to go, similar to a handler high up in the hierarchy.
Note that whichever way you implement this, you can discriminate among your fields, so that only the ones you designate will have either the handler or the behavior script "fire" when user entry is in progress.
Also, Klaus' offering should include a decimal point:
He knows this. He just forgot.
Craig
Note that whichever way you implement this, you can discriminate among your fields, so that only the ones you designate will have either the handler or the behavior script "fire" when user entry is in progress.
Also, Klaus' offering should include a decimal point:
Code: Select all
"0123456789."
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Text Boxes formatting text
Ah.
Some numbers but not all of them. I see. Uh huh. Well, at least your number set was of infinite length.
Craig
Some numbers but not all of them. I see. Uh huh. Well, at least your number set was of infinite length.
Craig
Last edited by dunbarx on Tue May 01, 2018 9:06 pm, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Text Boxes formatting text
Richard.
The above nonsense aside, do you need help with the other parts of your project? For example, the other four items you mentioned all require additional coding.
Craig
The above nonsense aside, do you need help with the other parts of your project? For example, the other four items you mentioned all require additional coding.
Craig
-
- Posts: 6
- Joined: Mon Apr 30, 2018 9:22 pm
Re: Text Boxes formatting text
Hi Craig,
Yes i would appreciate some help with that, thanks
Richard
Yes i would appreciate some help with that, thanks
Richard
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Text Boxes formatting text
Let's start using "field" instead of "text box". I never heard of a text box in LC until I met you.
#1- see the dictionary entry on "numberFormat" and also "format". Experiment and write back.
#2- This is a fun thing to do. Leave it for the moment.
#3- You can include chars such as "$" or "£' in your filtered data, and:
#4-
Is #4 robust enough to cover all bases? I don't know. Try it with all kinds of user entry and backspacing.
Experiment with several fields on a card, Do the above, and write back. We will then do #2, and THEN, talk about those high level handlers and behaviors.
Craig
#1- see the dictionary entry on "numberFormat" and also "format". Experiment and write back.
#2- This is a fun thing to do. Leave it for the moment.
#3- You can include chars such as "$" or "£' in your filtered data, and:
Code: Select all
if the text of field "yourField" contains "$" then set the backColor of field "yourField" to "red"
Code: Select all
if the text of field "yourField" = "0" then put "" into field "yourField"
Experiment with several fields on a card, Do the above, and write back. We will then do #2, and THEN, talk about those high level handlers and behaviors.
Craig
-
- Posts: 6
- Joined: Mon Apr 30, 2018 9:22 pm
Re: Text Boxes formatting text
Hi Craig,
Thanks for the pointers, will report back
Richard
Thanks for the pointers, will report back
Richard