Recent

Author Topic: [SOLVED] Is there a way to get the current/next object name in an on exit event?  (Read 3000 times)

wpflum

  • Sr. Member
  • ****
  • Posts: 287
I have a couple of TMaskedits  that are used to enter times into.  Right now I have it set that if you exit the first TMaskedit without entering anything the on exit event flags it and returns the focus to that TMaskedit.  This works well except that I have a button that will clear both fields, essentially resetting the form, that I cannot access unless there is something in the first TMaskedit.  Is there someway I can determine in the on exit event of that TMaskedit what the next object is or how it was selected, i.e. a mouse click instead of a return or tab key so I can ignore the verification depending on what was clicked?

I can here the complaining now if I leave it the way it is right now.   :D

« Last Edit: March 23, 2012, 04:10:23 pm by wpflum »

Avishai

  • Hero Member
  • *****
  • Posts: 1021
I think you must use a combination of Form1.KeyPreview + Form1.ActiveControl + MaskEdit1.OnExit and MaskEdit2.OnEnter.  But I do not think this will include MouseClick.  You could use MaskEdit2.OnMouseUp for this.
Lazarus Trunk / fpc 2.6.2 / Win32

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Seem to be even easier than that.  I forgot that I'm working on the forms unit page so all I had to do is check the name of the Active Control in the on exit event.  Looks like by the time the on exit event happens the forms current active control, i.e. the button I've clicked on, is set so all I had to do is check it against the names I want to allow even if the validation for the TEditMask isn't, well valid  :) 


Avishai

  • Hero Member
  • *****
  • Posts: 1021
Yes, TForm.ActiveControl is powerful, but easy to forget :)  I am glad you found what you need.
Lazarus Trunk / fpc 2.6.2 / Win32

 

TinyPortal © 2005-2018