Page 1 of 1

ExitField / CloseField do nothing when a user clicks on a button straight from a field

Posted: Wed Dec 04, 2019 10:04 am
by mrcoollion
Hi experts,

This is an old problem i cannot seem to solve.
I need to do some actions as soon as a user left a field (by clicking onto another field or on a button or outside the app ect...).
If a user after entering data into the field exits a field by clicking on another field the 'on ExitField' handler works fine.
However when a user after entering data into the field clicks on a button the 'on ExitField' is not triggered, neither are the 'on closefield' and the 'on focusout' handlers. This is probably because the cursor stays (blinking) in the field and therefore no handler is triggered?

These are all the handler i know that could/should solve this but none reacts when a user clicks on a button straight from the field.
I cannot use 'on rawkey...' because this triggers the 'DoFieldActions' handler each time a user enters a letter and that is to much!

Code: Select all

on closeField 
   DoFieldActions
end closeField
--
on exitField
   DoFieldActions
end exitField
--
on focusOut
   DoFieldActions
end focusOut
The only thing that does work is if I place the following code in the button to force LC to change the focus from field to button and then the 'on closeField ' handler is activated.

Code: Select all

set the traversalOn of me to true
   focus on me
Any ideas how to solve this from within the field ?

Regards,

Paul

Re: ExitField / CloseField do nothing when a user clicks on a button straight from a field

Posted: Wed Dec 04, 2019 10:24 am
by [-hh]
You could try on textchanged.

Re: ExitField / CloseField do nothing when a user clicks on a button straight from a field

Posted: Wed Dec 04, 2019 10:43 am
by mrcoollion
[-hh] wrote:
Wed Dec 04, 2019 10:24 am
You could try on textchanged.
Tried this but 'on textchanged' triggers on each change in the field , this is to much :-(

But thanks though :-)

Re: ExitField / CloseField do nothing when a user clicks on a button straight from a field

Posted: Wed Dec 04, 2019 10:50 am
by bogs
mrcoollion wrote:
Wed Dec 04, 2019 10:04 am
when a user after entering data into the field clicks on a button the 'on ExitField' is not triggered, neither are the 'on closefield' and the 'on focusout' handlers.
The first thought that came to me was similar to your focus change, if you know you want something to happen or you need (something from the field) on the button click, create a handler and launch it in the first line of the button click or, if the code is short enough, just put it as the first few lines of the button handler.

Otherwise, if your just looking for changes in the field, text changed works, stuffing the field into a variable at the beginning/end works, etc. as Hermann says. You can see a variation of these techniques here. You'll notice that I compare the current field to the contents in the variable, when xxx number of characters are different, it triggers the prompt to save.

Re: ExitField / CloseField do nothing when a user clicks on a button straight from a field

Posted: Wed Dec 04, 2019 11:31 am
by mrcoollion
Thanks for the lesson bogs :D ,

For now i opted for the 'focus change' option. This is the easiest way to achieve my goals.

Regards,

Paul

Re: ExitField / CloseField do nothing when a user clicks on a button straight from a field

Posted: Wed Dec 04, 2019 11:36 am
by Klaus
Hi Paul,

I had a similar problem on my Mac. On the Mac "traveralon" does not seem to work all the times in a button,
means does NOT remove focus from other objects as it should.
I did:

Code: Select all

on mouseup
  ## FORCE close/exitfield or whatever
  focus on nothing
  ## my mouseup stuff here...
end mouseup
Best

Klaus

Re: ExitField / CloseField do nothing when a user clicks on a button straight from a field

Posted: Wed Dec 04, 2019 2:29 pm
by mrcoollion
Thanks Klaus,

That is even shorter and it works :D