Skip to content

Instantly share code, notes, and snippets.

@TechNinjaWeb
Last active January 22, 2017 05:30
Show Gist options
  • Save TechNinjaWeb/b2850d0cc6637a5289bfffc9d22c7832 to your computer and use it in GitHub Desktop.
Save TechNinjaWeb/b2850d0cc6637a5289bfffc9d22c7832 to your computer and use it in GitHub Desktop.
Handling event detection and intent
Private LastActiveControl As Control = Me ' initialize on form creation
Protected Overrides Sub UpdateDefaultButton()
' Just added a IsNot condition to clarity
If (LastActiveControl Is txtNumberOfDrinks) AndAlso
((ActiveControl Is btnClear) OrElse (ActiveControl Is btnExit)) Then
' Only problem is that it tries to validate twice upon tabbing away (only once on click)
ElseIf (LastActiveControl Is txtNumberOfDrinks) AndAlso
((ActiveControl IsNot btnClear) OrElse (ActiveControl IsNot btnExit)) Then
validateForm()
End If
LastActiveControl = ActiveControl ' Store this for the next time Focus changes
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment