Home Forums Software Development ActivationFocusChanged

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1425
    Saad
    Participant

    In a WPF/C# application I have the following configuration:

    <Setter Property="eyeX:Behavior.Activatable" Value="TentativeFocusEnabled" />
     <EventSetter Event="eyeX:Behavior.Activate" Handler="Button_OnEyeXActivate" />
     <EventSetter Event="eyeX:Behavior.ActivationFocusChanged" Handler="Button_OnEyeXActivationFocusChanged" />

    In the Button_OnEyeXActivationFocusChanged(object sender, RoutedEventArgs args) event, I am trying to get the current activation status i.e., if the user is looking a the button or not.

    Is this possible?

    Thanks!
    Saad

    #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.

    #18203
    Yukio Okuno
    Participant

    Hi Jenny,

    This post helped me so much. I’m using ActivationFocusChanged and I would like to know how can I delay user’s eye-gaze.

    Thank you,
    Yukio.

    #18208
    Grant [Tobii]
    Keymaster

    Hi @yukio-okuno, could you kindly clarify your request. I understand you wish to create a delay timer before reacting to a gaze aware presence? In this case, you can setup a simple timer loop from .Net such as the stopwatch class

    using System.Diagnostics;
    //...
    Stopwatch timer = new Stopwatch();
    timer.Start();
    while(timer.Elapsed.TotalSeconds < Xseconds)
    {
        // do something
    }
    timer.Stop();

    It would also help if you could clarify which platform and SDK you are using. Thanks.

    #18209
    Grant [Tobii]
    Keymaster

    Hi @yukio-okuno, could you kindly clarify your request. I understand you wish to create a delay timer before reacting to a gaze aware presence? In this case, you can setup a simple timer loop from .Net such as the stopwatch class

    using System.Diagnostics;
    //...
    Stopwatch timer = new Stopwatch();
    timer.Start();
    while(timer.Elapsed.TotalSeconds < Xseconds)
    {
        // do something
    }
    timer.Stop();

    It would also help if you could clarify which platform and SDK you are using. Thanks.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.