Re: NewEra 2.2 Superfield focusout() not working!!
Posted in 1997
Tim Simpson wrote in article ... >I have a free form supertable and a button. I have discovered that the >focusout() event only happens when focus transfers to another >superfield. If the user tabs to the button instead, the focusout() event >doesn't happen until focus moves to another superfield!! > >How stupid! If focus moves from a control on the window why doesn't it >happen. > >Any thoughts to a simple solution? Yes, very very very stupid. If you wish to do validation on focus out then A) Do validation on exit of screen! B) If you have several superfields and the problem occurs when tabbing out of the last one onto a non superfield then you could paste another "dummy" superfield on the screen which becomes the last superfield in the tab order. When you tab out of your "real" last superfield it will move into your dummy superfield which has code in the focus in event to call focus on the normal non superfield control that would have got focus had you not put in the dummy superfield. If you move this dummy superfield out of visibility then the effect will be that when you tab out of the last visible superfield the dummy invisible superfield will gain focus. this WILL cause a focus out on your "real" superfield and executing your required code. whent he dummy superfield gains foucs it your code on the focus in event will cause focus to be moved to a non superfield control. In summary cause superfield focus on a non visible superfield which automatically skips to another control (but it still holds superfield focus). There is still a problem however. If the user is in the last "real" superfield and clicks on a non superfield (instead of tabbing) this will not work!!! C) On focus in of every non superfield control you call a function which validates the currently focused superfield. (Quite messy and a bit excessive and could cause problems if validation such as "can't be blank" is used !) I do not think there is a quick or simple solution as using the mouse there is no event generated making it difficult to code round something that doesn't happen! On focus in you do not know where you came from. You could coded a function on the focus in event of every control to set a global variable to store a record of where focus has been. You could then call validation on focus in which passes the previous control and checks if is valid to leave it. This can cause infinite loops as when you focus in on the 2nd object you could cause focus back on 1st object (which was invalid) This focus in on object 1 would cause validation on object 2. If the are both invalid you well get an infinite event loop unless you somehow prevent it (this is getting very heavy). This is further complicated by the fact that "focus in" event does not always get generated when you cause focus on an object (as adivsed by Informix)!!!! Our solution was to validation on screen exit as the coding gets far too complicated as you try and code round the problems. > >-- >Tim Simpson >