Numbers in text fields

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Re: Numbers in text fields

Post by dalkin » Sat Jan 30, 2021 1:03 am

The bug is/was something different ... but nevertheless ...

The workaround will be to invalidate entry if the first character is a number, so any help there would be appreciated. I've been trying with keyUp in field but I can't get it to work. This is the current button code:

Code: Select all

on mouseUp pButtonNumber
   ask "Please enter a name for the project."
   
 if the result is not "cancel" then
      put it into tName
      
      clone card "Lyricist"
      put the long id of it into tCardID
      put tName into field "Title" of tCardID
      set the name of tCardID to tName
      
      put return before line 1 of field "Index" of card "Navigation"
      put tName before field "Index" of card "Navigation"
   end if
end mouseUp
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Numbers in text fields

Post by dunbarx » Sat Jan 30, 2021 2:06 am

Hi.

Several fun ways to prevent a number from being entered first in a field, but you are asking to prevent entry from an ask dialog. Because the dialog has to be dismissed before anything can happen, and no messages are sent from any modal gadget, you can only check the user entry and act accordingly. So something like (pseudo):

Code: Select all

on mouseUp
   ask "Enter Project Name"
   if char 1 of it is a number then answer "Sorry, no beginning munbers. Try Again"
   else doYourThing
end mouseUp
Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Numbers in text fields

Post by dunbarx » Sat Jan 30, 2021 2:39 am

Why not make your own "Ask" gadget? This could easily be constructed to look exactly like the native one if you care to.

Now you have control over each user keyStroke. So in a field, likely required to build the thing at all, you can, in the field script:

Code: Select all

on keyDown tKey
   if the length of me >= 1 then pass keyDown
   if the length of me = 0 and tKey is not a number then pass keyDown
end keyDown
Now it simply ignores char 1 if it is a number.

Craig

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Re: Numbers in text fields

Post by dalkin » Sat Jan 30, 2021 8:40 am

Many thanks Craig. This is why you earn the big bucks.
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Numbers in text fields

Post by bogs » Sat Jan 30, 2021 2:56 pm

Maybe I missed a left turn in this thread somewhere along the way, but if I haven't, what I get from reading it is :
1. you want a name to create a card
2. you want to be able to use any legal name to apply to it, starting with a number or letter
3. you want to then create the card
4. you want a list of the cards.

Wouldn't this suffice ?
NumbersInTextFields.zip
(1.72 KiB) Downloaded 152 times
I should add that this is not a comprehensive or even well written set of handlers, it is mostly composed to be easily understood. I think a lot of it should be reduced to functions, and it certainly is not elegant in any way, shape, or form.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Numbers in text fields

Post by richmond62 » Sat Jan 30, 2021 4:26 pm

any legal name to apply to it, starting with a number or letter
Obviously, inwith the LiveCode world (at least) a name starting with a number is NOT legal.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Numbers in text fields

Post by bogs » Sat Jan 30, 2021 4:39 pm

Actually, I was thinking more along the lines of weird symbols or null characters heh.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Numbers in text fields

Post by dunbarx » Sat Jan 30, 2021 4:57 pm

Obviously, inwith the LiveCode world (at least) a name starting with a number is NOT legal.
Richmond, in LC there are no proscriptions against any name of any kind starting with a number. What did you mean?

I do love it when you use the word "inwith".

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Numbers in text fields

Post by richmond62 » Sat Jan 30, 2021 5:03 pm

no proscriptions
Possibly not, but certainly awkward as we have seen.

What's wrong with 'inwith'?

Aah:
-
Screenshot 2021-01-30 at 18.02.34.png
Screenshot 2021-01-30 at 18.02.34.png (6.18 KiB) Viewed 5183 times
-
I have obviously been in Bulgaria too long. 8)
Last edited by richmond62 on Sat Jan 30, 2021 5:42 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Numbers in text fields

Post by FourthWorld » Sat Jan 30, 2021 5:30 pm

richmond62 wrote:
Sat Jan 30, 2021 5:03 pm
no proscriptions
Possibly not, but certainly awkward as we have seen.
I haven't seen it.

The only limitation with numbers in names I've seen is when a name is a number, with no other characters present. In such a case LC is unable to determine whether you're asking for the object by name or number. But mixing alpha and numeric characters is not something I've seen a problem with.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Numbers in text fields

Post by richmond62 » Sat Jan 30, 2021 5:41 pm

I set up a stack with 4 cards named respectively "1KARD", "2KARD", "3KARD", "4KARD"
and even the in-built navigation would not behave itself ( View/Go Next ).
Nothing quite like quoting oneself. 8)

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Numbers in text fields

Post by bogs » Sat Jan 30, 2021 7:24 pm

FourthWorld wrote:
Sat Jan 30, 2021 5:30 pm
richmond62 wrote:
Sat Jan 30, 2021 5:03 pm
no proscriptions
Possibly not, but certainly awkward as we have seen.
I haven't seen it.

The only limitation with numbers in names I've seen is when a name is a number, with no other characters present. In such a case LC is unable to determine whether you're asking for the object by name or number. But mixing alpha and numeric characters is not something I've seen a problem with.
@Richard - and it is likely you wouldn't have seen it, unless you are using OSX Big Sur on any regular basis, I'm guessing.
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Numbers in text fields

Post by FourthWorld » Sat Jan 30, 2021 7:44 pm

Exactly, Bogs. There's a confirmed big report for this.

I was addressing a more general misunderstanding about object names that begin with numerals.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Numbers in text fields

Post by bogs » Sat Jan 30, 2021 7:54 pm

Ahh, gotcha.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Numbers in text fields

Post by dunbarx » Sat Jan 30, 2021 8:31 pm

So it is Big Sur where there is an issue with naming a button, card or stack "6abc". How could the OS affect LC that way?

And it isn't that LC gets confused about what to do with a button named "42". Since there is an intrinsic ambiguity there, LC chooses to treat it as a layer reference, not a name, and move on. Consistency is what is important; style is a matter of, er, style.

Craig

Post Reply