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
Location: https://tunnel-rush.io

Auto Focus On Edit Field

Post by willowherbrestroom » Thu Apr 11, 2024 5:02 am

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: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Auto Focus On Edit Field

Post by Klaus » Thu Apr 11, 2024 8:54 am

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: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Auto Focus On Edit Field

Post by richmond62 » Thu Apr 11, 2024 10:22 am

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: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Auto Focus On Edit Field

Post by dunbarx » Thu Apr 11, 2024 2:33 pm

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: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Auto Focus On Edit Field

Post by SparkOut » Thu Apr 11, 2024 5:18 pm

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: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Auto Focus On Edit Field

Post by dunbarx » Thu Apr 11, 2024 5:23 pm

Jwack?

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

Craig

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

Re: Auto Focus On Edit Field

Post by SparkOut » Thu Apr 11, 2024 5:25 pm

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: 7240
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Auto Focus On Edit Field

Post by jacque » Fri Apr 12, 2024 5:39 pm

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: 2688
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Auto Focus On Edit Field

Post by stam » Fri Apr 12, 2024 6:22 pm

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

Return to “iOS Deployment”