Author Topic: Focus to InForm  (Read 7450 times)

0 Members and 1 Guest are viewing this topic.

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Focus to InForm
« on: August 01, 2018, 12:22:09 pm »
Hello,
How could I change the focus of a texbox to another control?
I want to change from one texbox to the next texbox by pressing the Enter key.
I know that the code would be like that:
           
SUB __UI_KeyPress (id AS LONG)
       SELECT CASE id
            CASE Texbox1TB
                    IF __UI_KeyHit = 13 THEN
             
                       ?????????????
                   
                    END IF
...

Thanks

FellippeHeitor

  • Guest
Re: Focus to InForm
« Reply #1 on: August 01, 2018, 01:13:53 pm »
Use the SetFocus method:

Code: QB64: [Select]
  1. SUB __UI_KeyPress (id AS LONG)
  2.        SELECT CASE id
  3.             CASE Texbox1TB
  4.                     IF __UI_KeyHit = 13 THEN
  5.              
  6.                        SetFocus TextBox2TB 'or whatever your control name is
  7.                    
  8.                     END IF
  9. ...

That'll set focus to the desired control and, if it's a textbox, will automatically select all of its contents.

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: Focus to InForm
« Reply #2 on: August 01, 2018, 01:22:28 pm »
Hello,
How could I change the focus of a texbox to another control?
I want to change from one texbox to the next texbox by pressing the Enter key.
I know that the code would be like that:
           
SUB __UI_KeyPress (id AS LONG)
       SELECT CASE id
            CASE Texbox1TB
                    IF __UI_KeyHit = 13 THEN
             
                       ?????????????
                   
                    END IF
...

Thanks


Just to let you know, the standard for that functionality is to use Tab not Enter. Enter is supposed to signify that you are finished with input and need to execute. If you are not planning on sharing your software, and you only plan on using it yourself that's one thing, but if you plan on sharing it, that would probably be pretty non-intuitive for a user.
I am from a Kazakhstan, we follow the hawk.

FellippeHeitor

  • Guest
Re: Focus to InForm
« Reply #3 on: August 01, 2018, 01:31:44 pm »
Tab works by default with InForm.

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Re: Focus to InForm
« Reply #4 on: August 01, 2018, 02:23:38 pm »
Thank FellipeHeitor.

Quote
Just to let you know, the standard for that functionality is to use Tab not Enter. Enter is supposed to signify that you are finished with input and need to execute. If you are not planning on sharing your software, and you only plan on using it yourself that's one thing, but if you plan on sharing it, that would probably be pretty non-intuitive for a user.

Precisely in my case it is the opposite. I want to update a billing program in which users are accustomed to using the Enter key to confirm each field. This is very comfortable especially if the numeric keyboard is used.

thanks



FellippeHeitor

  • Guest
Re: Focus to InForm
« Reply #5 on: August 01, 2018, 02:45:02 pm »
Thank FellipeHeitor.

My pleasure! Let me know if you need any extra assistance with InForm. I'm always around.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Focus to InForm
« Reply #6 on: August 02, 2018, 02:24:58 pm »
I recently did a small application where I wanted the ENTER/RETURN key to send a tab, this is VB6 code
Code: QB64: [Select]
  1. Private Sub Text10_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = 13 Then                ' Enter = Tab
  3.     SendKeys "{tab}"
  4.     KeyAscii = 0
  5.