Home Forums Software Development Button that activates with gaze Reply To: Button that activates with gaze

#8349
Borja Vicinay
Participant

I want to create a number keypad (1-9) where you can click a button by dwelling 800 miliseconds over it.

Executes once the window is loaded:

bounds1 = GetItemBounds(btn1);
win1 = virtualWindowsAgent.CreateFreeFloatingVirtualWindowAsync("window1", bounds1).Result;
agent1 = host.InitializeVirtualInteractorAgent(win1.Id);
agent1
    .AddInteractorFor(bounds1)
    .WithGazeAware()
    .HasGaze(() => btnEnter(1))
    .LostGaze(() => btnLeave(1));

Function declarations:

private void btnEnter(int btn)
{
    timer.Restart();
    currBtn = btn;
    while (currBtn == btn)
    {
        if (timer.ElapsedMilliseconds > 800 && currBtn == btn)
        {
            addText(btn.ToString());
            timer.Restart();
            break;
        }
    }

}
private void btnLeave(int btn)
{
    timer.Restart();
    currBtn = 0;
}

This is not working correctly. When I gaze over 1 button it works (after the dwell time) but if I try to type 23 for example it types in other numbers in between. Are the enter/leave calls asynchronous?

Many thanks for your help!