Home Forums Software Development ActivationFocusChanged Reply To: ActivationFocusChanged

#1430
Jenny [Tobii]
Participant

Hi Saad,

Yes, it is possible. There is an attached property Behavior.ActivationFocus which holds the current value of the activation focus:
– None (if the element does not have any activation focus)
– HasActivationFocus (the user’s eye-gaze is on the element and the user is pressing down the activation key – it would be activated if the activation key was released now)
– HasTentativeActivationFocus (the user’s eye-gaze is on the element)

In the code-behind you can do the following to access the current state of the activation focus of the element:

using EyeXFramework;
using EyeXFramework.Wpf;
...

private void Button_OnEyeXActivationFocusChanged(object sender, RoutedEventArgs e)
{
	var element = e.Source as FrameworkElement;
	var activationFocus = element.GetActivationFocus();

	if (ActivationFocus.HasActivationFocus == activationFocus ||
		ActivationFocus.HasTentativeActivationFocus == activationFocus)
	{
		// the element has activation focus (the user's eye-gaze is on the element)
	}
}

At last, a little friendly side note: There is a difference between “the user is looking at the gui element” and “the user’s eye-gaze is on the gui element”. The latter is “instant”. With Tentative Focus enabled, the element receives ActivationFocusChanged events whenever the user’s eye-gaze is simply glancing over or passing the element, and not really looking at the element. Depending on what you want to do with the activation focus state, you might want to use some sort of delayed response to these events. The HasActivationFocus state tells us a little more, since if the user is pressing down the activation key it is more likely that the user is looking intentionally at the element.