Auto Focus On Edit Field

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
willowherbrestroom
Posts: 1
Joined: Thu Apr 11, 2024 4:55 am

Auto Focus On Edit Field

Post 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!
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Auto Focus On Edit Field

Post 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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10422
Joined: Fri Feb 19, 2010 10:17 am

Re: Auto Focus On Edit Field

Post 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)
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Auto Focus On Edit Field

Post 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
SparkOut
Posts: 2987
Joined: Sun Sep 23, 2007 4:58 pm

Re: Auto Focus On Edit Field

Post 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.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Auto Focus On Edit Field

Post by dunbarx »

Jwack?

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

Craig
SparkOut
Posts: 2987
Joined: Sun Sep 23, 2007 4:58 pm

Re: Auto Focus On Edit Field

Post by SparkOut »

She'll tell you the story :lol:

Or you can re-read it yourself viewtopic.php?p=160350#p160350
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Auto Focus On Edit Field

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
stam
Posts: 3214
Joined: Sun Jun 04, 2006 9:39 pm

Re: Auto Focus On Edit Field

Post 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
Post Reply