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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
AlessioForconi
Posts: 90
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: 2718
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
https://alternatic.ch

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7245
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: 2718
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
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9846
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

AlessioForconi
Posts: 90
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”