QB64.org Forum

QB64 Team Software => InForm Discussion => Topic started by: Juanjogomez on August 01, 2018, 12:22:09 pm

Title: Focus to InForm
Post by: Juanjogomez 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
Title: Re: Focus to InForm
Post by: FellippeHeitor 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.
Title: Re: Focus to InForm
Post by: keybone 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.
Title: Re: Focus to InForm
Post by: FellippeHeitor on August 01, 2018, 01:31:44 pm
Tab works by default with InForm.
Title: Re: Focus to InForm
Post by: Juanjogomez 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


Title: Re: Focus to InForm
Post by: FellippeHeitor 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.
Title: Re: Focus to InForm
Post by: jack 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.