tabKey o exitField

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
AlessioForconi
Posts: 77
Joined: Sun Feb 15, 2015 2:51 pm

tabKey o exitField

Post by AlessioForconi » Sun Apr 14, 2019 10:21 am

Hi everyone,

I have a text validation function in a field that I call when I go to the next field.
Since I wish I could use both the tab key and the mouse to move, I call it both on tabKey and on exitField (if I use the mouse).
The fact is that after tabKey is still called exitField (which is right).

It's possible to make sure not to invoke exitField if it has been called tabKey?

Thank you

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2311
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: tabKey o exitField

Post by jmburnod » Sun Apr 14, 2019 11:52 am

Hi Alessio,
It seems possible.
Here is a way to do it:

Code: Select all

on exitfield
   if the uMyUseExitFld of this cd then -- message comes from mouse
      beep
   else -- message comes from tabkey 
      
   end if
end exitfield

on tabkey
   setMyUseExitFld  false
   send "setMyUseExitFld  true"  to me in 10 milliseconds
   pass tabkey
end tabkey

on setMyUseExitFld pBool
   set the uMyUseExitFld of this cd to pBool
end setMyUseExitFld
I guess a more clever solution will come.

Edit: All handlers are on cd script
Best regards
Jean-Marc

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4916
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: tabKey o exitField

Post by jacque » Sun Apr 14, 2019 4:26 pm

Since exitfield is always sent when leaving the field by either mouse or tab, I'd just validate on exitfield only. Is there some reason it needs to be done in tab also?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2311
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: tabKey o exitField

Post by jmburnod » Sun Apr 14, 2019 4:48 pm

@Alessio
Just after i've written my post I wondered why you need it.
As I have guessed, Jacque posted a smartest answer 8)
Jean-Marc

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6495
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: tabKey o exitField

Post by FourthWorld » Sun Apr 14, 2019 7:59 pm

You might consider closeField rather than exitField. closeField is sent when leaving a field after the contents have changed, while exitField is sent when the field has not changed. Probably not much validation needed when the field doesn't change. ;)
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

AlessioForconi
Posts: 77
Joined: Sun Feb 15, 2015 2:51 pm

Re: tabKey o exitField

Post by AlessioForconi » Mon Apr 15, 2019 3:33 pm

FourthWorld wrote:
Sun Apr 14, 2019 7:59 pm
You might consider closeField rather than exitField. closeField is sent when leaving a field after the contents have changed, while exitField is sent when the field has not changed. Probably not much validation needed when the field doesn't change. ;)
You're right, I will do so.

Thanks

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”