Sign in to follow this  
indigo

Tab browsing between Edit Boxes

Recommended Posts

Hi,

Is there a way to jump between edit boxes / buttons on a page by pressing i.e. the tab key? I've tried via speed key and to look online but I could never find anything.

Thanks in advance for your support!

Share this post


Link to post
Share on other sites

Yes, but it is not as easy as I would hope.  You need to create a sequence called OnKeyDown and then add some script.  For example, if you had a user/password popup:

if (component.userNameEdit.GetFocus())
   if (key == 9)
      component.userPasswordEdit.SetFocus()
      return
   endif
   if (key == 13)
      enteredName = component.userNameEdit.strContents
      enteredPass = component.UserPasswordEdit.strContents
      Login(EnteredName,EnteredPass)
   endif      
endif
if (component.userPasswordEdit.GetFocus())
   if (key == 9)
      component.UserNameEdit.SetFocus()
      return
   endif
   if (key == 13)
      enteredName = component.userNameEdit.strContents
      enteredPass = component.UserPasswordEdit.strContents
      Login(EnteredName,EnteredPass)
   endif      
endif

Login() is just some function that performs the login.  The key parts are the GetFocus() which returns if the specified component is focused, SetFocus() which sets a component to have focus, and the checks for "key" which is a parameter passed to OnKeyDown with the key code of the key pressed.  9 is tab, 13 is carriage return.

Share this post


Link to post
Share on other sites

Thanks for the reply, I only now managed to get around to implementing this, so sorry for the delay.

I found the sample code in the DAQFactory folder and I guess that code snippet you provided has to be added to a sequence called "OnKeyDown" for it to work. I tried to do the following (which tabs between multiple edit boxes):

switch
   case(component.edit_box1.GetFocus())
      component.edit_box2.SetFocus()
   case(component.edit_box2.GetFocus())
      component.submit_button.SetFocus()
endcase

But, it doesn't seem to be able to put buttons into focus, is this correct? Or is my code snippet wrong? Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this