Page 1 of 2

Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 9:41 pm
by rumplestiltskin
Alrighty, my lot in life is to find bugs...

I have three fields in a stack. None of the fields have any handlers in them. All three have "Tab on Return" and "Don't Wrap" checked. Yet, if I type something into any of the fields and press the Return key (the one in the main part of the keyboard above right-shift), a return char is added and the text I entered moves upward. This behavior persists regardless of the settings of "Tab on Return" and "Don't Wrap". The tab key works as expected but I need to intercept bad user behavior.

IIRC, in previous versions of LC, these field settings were respected. Do I need to add some sort of "returnInField" handler to each field and, if so, what would I have the handler do?

Thanks,
Barry

LC 8.1.9 Indy.

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 9:53 pm
by Klaus
Hi Barry,

a quick test confirmed this issue! :-/

But looks like the bug has already been reported, so I added a comment:
http://quality.livecode.com/show_bug.cgi?id=20948

Best

Klaus

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 9:57 pm
by rumplestiltskin
Hello, Klaus! Thanks for your reply. I read your comment at the bug page.

Until the LC crew fixes this, what would you recommend I use as a handler to intercept the "return" and send the focus to the next field?

Thanks,
Barry

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:23 pm
by bogs
Just a guess, but probably something like (not tested)

Code: Select all

on returnInField
	put tab after field "yourField"
end returnInField

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:25 pm
by rumplestiltskin
Just read your replay as I was about to post this:

Code: Select all

on rawKeyDown pkey
   if pkey is 64293 then
      exit rawKeyDown
   else
      pass rawKeyDown
   end if
end rawKeyDown pkey
64293 is the raw code for "Return"

Seems to work but I'll try yours as it's certainly less verbose.

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:27 pm
by rumplestiltskin
bogs wrote:
Wed Mar 21, 2018 10:23 pm
Just a guess, but probably something like (not tested)

Code: Select all

on returnInField
	put tab after field "yourField"
end returnInField
Nope; just adds a tab character to the end of the current field. Mine seems to work okay.

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:34 pm
by rumplestiltskin
rumplestiltskin wrote:
Wed Mar 21, 2018 10:27 pm
bogs wrote:
Wed Mar 21, 2018 10:23 pm
Just a guess, but probably something like (not tested)

Code: Select all

on returnInField
	put tab after field "yourField"
end returnInField
Nope; just adds a tab character to the end of the current field. Mine seems to work okay.
Nope, I thought it was working but no more. *sigh* I'll keep trying.

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:39 pm
by LiveCode_Panos
Does that work in your use case?

Code: Select all

on returnInField
   focus on fld "myNextField"
end returnInField
Panos
--

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:41 pm
by Klaus
This seems to work:

Code: Select all

on returnInField
 type TAB
end returninfield

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:49 pm
by bogs
rumplestiltskin wrote:
Wed Mar 21, 2018 10:27 pm
bogs wrote:
Wed Mar 21, 2018 10:23 pm
Just a guess, but probably something like (not tested)

Code: Select all

on returnInField
	put tab after field "yourField"
end returnInField
Nope; just adds a tab character to the end of the current field. Mine seems to work okay.
My bad, I misinterpreted what you were shooting for, totally on me, I thought you wanted to add a tab at the end instead of a return :oops: What Klaus said though :D

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 10:55 pm
by FourthWorld
Barry, what is the height of the field, and what is the textHeight of the field?

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 11:02 pm
by rumplestiltskin
Klaus wrote:
Wed Mar 21, 2018 10:41 pm
This seems to work:

Code: Select all

on returnInField
 type TAB
end returninfield
Yep! That did it. Restores proper behavior. One the bug has been eliminated, I can eliminate this extra code but it's nice to know it will continue working even if I forget.

Simple solution. The best ones often are.

Thanks again!

Barry

PS - I was posting and the forum advised me of a new post so here are the answers:

put Height of field c1 returns 29
put textHeight of field c1 returns nothing
(You probably meant "effective textHeight" and that returned 21)
In the field object properties, it shows a textHeight of 21 ("fixed") and a test size of 16.
Hope this is meaningful.

Re: Return in field where it's told not to happen

Posted: Wed Mar 21, 2018 11:57 pm
by FourthWorld
rumplestiltskin wrote:
Wed Mar 21, 2018 11:02 pm
PS - I was posting and the forum advised me of a new post so here are the answers:

put Height of field c1 returns 29
put textHeight of field c1 returns nothing
(You probably meant "effective textHeight" and that returned 21)
In the field object properties, it shows a textHeight of 21 ("fixed") and a test size of 16.
Hope this is meaningful.
Meaningful, but not as helpful as I'd hoped. I was hoping to reproduce the problem, but here, using v9dp1 on Ubuntu 14.04,fields set to those metrics behave as expected. I wish I had something more useful to offer for what you're seeing.

Re: Return in field where it's told not to happen

Posted: Thu Mar 22, 2018 4:50 am
by rumplestiltskin
I don't know if this is meaningful or not but I just discovered I had somehow made the three fields in my stack invisible but, just as strange, had selected "Show invisible objects"; so my fields (though "visible" was unchecked) were showing up and displaying that bizarre behavior that caused me to start this thread. I discovered this a few minutes ago when, inexplicably, the three fields disappeared. I figured they had somehow become invisible so I used the "Show invisible objects" menu item and then checked the "visible" checkbox for each field. I saved everything, quit LC, and double-clicked my stack to re-launch LC and open things. Now the expected (non-buggy) "Return-in-field-yields-a-tab-to-the-next-field" behavior seems to be consistently fine.
{a few minutes pass while I check some other things...}

Okay, now I've tried this with checking and unchecking the "resizable" checkbox in the stack's properties and I'm finding the problem ("returns" generating new lines in the field) if I check the checkbox. If I leave the "resizable" checkbox unchecked, this seems to be working properly now.

I'll note my original thought (see paragraph 1, above) did not include the "resizable" checkbox but, indeed, that stack -was- set to be resizable. Once I unchecked it, it looks like it's working properly.

So I'll let Klaus and others whose pay grade is much higher than mine test this. Maybe I got lucky and zeroed in on the issue? Heck; even a stopped watch is correct twice a day! :lol:

Re: Return in field where it's told not to happen

Posted: Thu Mar 22, 2018 3:24 pm
by Klaus
Please take a look at my last comment for that bug!
http://quality.livecode.com/show_bug.cgi?id=20948

The expalantion is really not straightforward, but the observed behavior is definitively correct, once you understand what is going on. Create a ONE line text field with AUTOTAB and see yourself. :D