Page 2 of 3

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 1:03 am
by dalkin
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

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 2:06 am
by dunbarx
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

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 2:39 am
by dunbarx
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

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 8:40 am
by dalkin
Many thanks Craig. This is why you earn the big bucks.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 2:56 pm
by bogs
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 244 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.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 4:26 pm
by richmond62
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.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 4:39 pm
by bogs
Actually, I was thinking more along the lines of weird symbols or null characters heh.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 4:57 pm
by dunbarx
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

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 5:03 pm
by richmond62
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 6543 times
-
I have obviously been in Bulgaria too long. 8)

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 5:30 pm
by FourthWorld
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.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 5:41 pm
by richmond62
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)

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 7:24 pm
by bogs
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.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 7:44 pm
by FourthWorld
Exactly, Bogs. There's a confirmed big report for this.

I was addressing a more general misunderstanding about object names that begin with numerals.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 7:54 pm
by bogs
Ahh, gotcha.

Re: Numbers in text fields

Posted: Sat Jan 30, 2021 8:31 pm
by dunbarx
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