[Solved] Textbox set focus

Post

Posted
Rating:
#1 (In Topic #1163)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Hi everyone,

Ok so this may be the stupidest question I have ever asked but I just wanted to make sure i am not going nuts

When my program starts i use

Code (gambas)

  1. textbox1.setfocus

but I can not type inside it (i have to click on it with the mouse for the cursor to show up inside the text box


is there a way to make it so I can type with out having to click on it with the mouse?

I am sure I am missing a simple step here
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
 Works as expected here.

Your code must be giving something focus that you don't really want.
Online now: No Back to the top

Post

Posted
Rating:
#3
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

BruceSteers said

Works as expected here.

Your code must be giving something focus that you don't really want.

That is super strange

attached is my project so far could you see if it works your end if it does then it means there is something not right with my system (GTK3)

to test if you can type with out clicking then you can login with algpos for both user and password

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
 I'm not sure why it does not work, something to do with the form being loaded into a workspace.
After the workspace has Added the frmSignon it seems to give it focus.
I added this to the end of Main() in Startup.class

Print Application.ActiveControl

The result was frmSignon had focus not the textbox.

So I tried a few things then found if you change Form_Open() in frmSignon to Form_Show() then it works.
(I have often found Form_Open() to not work as expected when not opening a form the usual way but Form_Show() does)

The other option would be to make txtUserID Public and use frmSignon.txtUserID.SetFocus() at the end of Startup.class/Main()
Online now: No Back to the top

Post

Posted
Rating:
#5
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

BruceSteers said

I'm not sure why it does not work, something to do with the form being loaded into a workspace.
After the workspace has Added the frmSignon it seems to give it focus.
I added this to the end of Main() in Startup.class

Print Application.ActiveControl

The result was frmSignon had focus not the textbox.

So I tried a few things then found if you change Form_Open() in frmSignon to Form_Show() then it works.
(I have often found Form_Open() to not work as expected when not opening a form the usual way but Form_Show() does)

The other option would be to make txtUserID Public and use frmSignon.txtUserID.SetFocus() at the end of Startup.class/Main()

Thanks for looking but even when I changed the txtUserID to public and use frmSignon.txtUserID.SetFocus() at the end of Startup.class/Main()
it does not set focus to it. once I have clicked inside the textbox it works fine (lucky this is only for a internal support application I am designing) so I can put up with it for now
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
that is weird, it worked here just fine.
(although i had to comment out all the Connect calls)

what about the other fist more detailed method I said of changing frmSignon Form_Open() to Form_Show() rather than the additional alternative.

frmSignon.class

Code (gambas)

  1. ' Gambas class file
  2.  
  3. Public Sub Form_Show()
  4.  
  5.     btnClear_Click
  6.  
  7.  
  8.  
Online now: No Back to the top

Post

Posted
Rating:
#7
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Sorted.

I had to add a wait 0.1 to the btnClear_click function and it now sets the focus and allows me to type in the box :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.