# field tabseq

**URL:** <https://forum.servoy.com/t/field-tabseq/9432>\
**Category:** Classic Servoy\
**Created:** [August 10, 2008, 3:19pm UTC](https://forum.servoy.com/t/field-tabseq/9432 "2008-08-10T15:19:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [August 10, 2008, 3:19pm UTC](https://forum.servoy.com/t/field-tabseq/9432/1 "2008-08-10T15:19:06Z")

</div>

Hi,

Is there a way to find out in which field the cursor is (tabseq #) ?

I use a masterform with tabpanels containing the real forms and fields.

If the user switches tabpanels i want to put the cursor on the first field of the form  
if this is the first time he enters the tabpanel.  
When he leaves the tabbpanel i want to save the tabseq# and put the cursor  
back into that field if he returns to that tabpanel.

Regards,

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [August 10, 2008, 4:52pm UTC](https://forum.servoy.com/t/field-tabseq/9432/2 "2008-08-10T16:52:37Z")

</div>

Hi Hans,

This is Servoy 4 ? If so you could use a form global to keep the fieldname in it that is set via an onFocusGained event on the fields.  
This way you could put the focus back to it when the onShow is hit again.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Hans\_Nieuwenhuis](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hans\_Nieuwenhuis](https://forum.servoy.com/u/Hans_Nieuwenhuis)\
**Post date:** [August 10, 2008, 5:15pm UTC](https://forum.servoy.com/t/field-tabseq/9432/3 "2008-08-10T17:15:21Z")

</div>

Hi Robert,

It is 3.5.6.

But i just found a way to do it and tested it.

Like you suggested. But since i could not use a form global variable i used  
a forms[\_form].active\_field. So i extended the form with my own variable.

Then i use a onFocusGained method to set this form variable and in  
the onTabChange i check if it is set and then set focus to that field.

Works fine !!

The onTabChange code =

```auto
_form=application.getMethodTriggerFormName()

if( forms[_form].elements.tabs)
{
	var _current = forms[_form].elements.tabs.tabIndex;
	var _formName = forms[_form].elements.tabs.getTabFormNameAt(_current)
}
else
{
	_formName=_form
}
if(!forms[_formName].act_field)
{
	forms[_formName].controller.focusFirstField()
}
else
{
	forms[_formName].elements[forms[_formName].act_field].requestFocus()
}

```

The onFocusGained code =

```auto
forms[application.getMethodTriggerFormName()].act_field=application.getMethodTriggerElementName()

```

Thanks anyway, always good to get feedback from expirienced users.

Regards,
