Page 1 of 1

Auto Focus On Edit Field

Posted: Thu Apr 11, 2024 5:02 am
by willowherbrestroom
Hi Guys!!!

I am trying to launch my app without automatically focusing on an edit field. I have the following code,

on openStack
focus on nothing
end openStack

That does not seem to work. Any ideas would be awesome!

Re: Auto Focus On Edit Field

Posted: Thu Apr 11, 2024 8:54 am
by Klaus
Hi willowherbrestroom,

welcome to the forum!

Try it with a little delay like:

Code: Select all

on openStack
  send "focus on nothing" to me in 10 
  ## if using a "naked" number LC presumes you mean TICKS
  ## 60 ticks = 1 second
end openStack
Best

Klaus

Re: Auto Focus On Edit Field

Posted: Thu Apr 11, 2024 10:22 am
by richmond62
That's much more sensible than what I have done several times:

I have had a 1 x 1 pixel field off-screen and set the focus after that. 8)

Re: Auto Focus On Edit Field

Posted: Thu Apr 11, 2024 2:33 pm
by dunbarx
Hi.

You will find that adding a short delay will solve issues that otherwise seem perfectly sound. Just because our logic and coding is OK, it does not mean that the physical running of the engine is up to speed with our thinking.

Often you can use a much shorter value than ten ticks. In fact, one tick is more than enough, and zero will probably also do in most cases.

Craig

Re: Auto Focus On Edit Field

Posted: Thu Apr 11, 2024 5:18 pm
by SparkOut
I think there might still be issues on mobile (not that I have encountered such in my usage) where not only does the first field take focus, it pops up the virtual keyboard. Hence the single pixel focus trick. Jwack would know.

Re: Auto Focus On Edit Field

Posted: Thu Apr 11, 2024 5:23 pm
by dunbarx
Jwack?

I think she is used to having her name manhandled, but this? :wink:

Craig

Re: Auto Focus On Edit Field

Posted: Thu Apr 11, 2024 5:25 pm
by SparkOut
She'll tell you the story :lol:

Or you can re-read it yourself viewtopic.php?p=160350#p160350

Re: Auto Focus On Edit Field

Posted: Fri Apr 12, 2024 5:39 pm
by jacque
SparkOut wants to be my brother. :)

The wait method probably works. I usually set the traversalOn of the card to false on preopencard and set it back to true with a send command at the end of opencard. A millisecond or two is usually enough of a lag.

Re: Auto Focus On Edit Field

Posted: Fri Apr 12, 2024 6:22 pm
by stam
In a similar situation, wait did not work for me - the field would still receive the focus.

In the end I had the traversalOn of the field set to false by default and set to true on tabKey, mouseDown (on locked fields) and openField in unlocked fields; and had then to set it to false on closeField/exitField. A faff, but it worked reliably which no other method really did for me...

Stam