Page 1 of 1
[Solved] Textbox set focus
Posted: Monday 25th December 2023 6:53pm
by AndyGable
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
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
Re: Textbox set focus
Posted: Monday 25th December 2023 7:12pm
by BruceSteers
Works as expected here.
Your code must be giving something focus that you don't really want.
Re: Textbox set focus
Posted: Monday 25th December 2023 8:00pm
by AndyGable
BruceSteers wrote: ↑Monday 25th December 2023 7:12pm
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
Re: Textbox set focus
Posted: Monday 25th December 2023 10:19pm
by BruceSteers
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()
Re: Textbox set focus
Posted: Tuesday 26th December 2023 12:10am
by AndyGable
BruceSteers wrote: ↑Monday 25th December 2023 10:19pm
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
Re: Textbox set focus
Posted: Tuesday 26th December 2023 12:43am
by BruceSteers
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
' Gambas class file
Public Sub Form_Show()
btnClear_Click
End
Re: Textbox set focus
Posted: Tuesday 26th December 2023 2:11am
by AndyGable
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