Tab browsing between Edit Boxes


Recommended Posts

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.

Link to comment
Share on other sites

  • 3 months later...

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share