Data Access Worldwide Knowledge Base
Article ID 2329 Article Title HOWTO: Know that the focus moved to an object outside of a container Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2329 KBase Category VDF (GENERAL) Date Created 06/15/2007 Last Edit Date 06/28/2007
Article Text
QUESTION:
I want to be notified when the user moves the focus to an object outside of a container (a group for example). The documentation for the Group class shows that OnKillFocus is available, but this seems to never be called.
ANSWER:
While the events OnKillFocus and OnSetFocus are really present in the Group class, they will never be called because an object of the Group class will never receive the focus.
If you add:
Procedure Exiting Handle hoDestination Returns Integer
Integer iRetVal
Forward Get msg_Exiting hoDestination To iRetVal
If (iRetVal = 0) Begin
Delegate Get FocusChangeNotification hoDestination To iRetval
End
Procedure_Return iRetVal
End_Procedure
to each of the container child objects (forms, buttons, spinforms etc) and add:
Function FocusChangeNotification Handle hoDestination Returns Boolean
// Sent by Exiting of all child objects of this container.
// The focus is about to change from a child object to hoDestination
//
If (Prior_Level (hoDestination) <> Self) Begin
// The new focus is outside this container: validate
// If validation fails refuse the focus change by
// returning a non-zero value (e.g. an error count)
//
Showln ("FocusChangeNotification in:" * String (Name (Self)))
Function_Return 1 // or 0
End
Else Begin
Function_Return 0
End
End_Function // FocusChangeNotification
to the container object, you will be notified in all cases where the system sends an Exiting message to the child object.
As you can read in KBase link below, this is not always the case but in most situations it will do.
Contributed By:
Igor van Houttum
Company: Data Access Europe
email: igor.van.houttum@dataaccess.eu
Web Site: http://www.dataaccess.eu
Web Links Related to this Article
DAW Knowledge Base article 2328: INFO: OnSetFocus/OnKillFocus versus Entering/Exiting
URL=http://www.dataaccess.com/KBPrint.asp?ArticleID=2328
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.