Sign in to follow this  
Followers 0
saywell

[solved] Focus to button after input filled

4 posts in this topic

#1 ·  Posted (edited)

Hi,

I have a GUI with an input field limited to 6 characters [digits required, but this is checked later]

Below it is a button that runs a function that reads the input, then odes stuff with it.

My question is, how can I make the button take focus as soon as the user has filled the input box with the 6 characters

. He would then type in 6 digits and hit return to run the function, rather tan tabbing or mouse-clicking the button.

I'm running in OnEventMode and the relevant bit of code is:

GUICtrlCreateLabel("Enter Hospital Number", 90, 190)
$HSPinput= GUICtrlCreateInput("", 120, 215, 50)
$limit = GUICtrlSetLimit($HSPinput, 6)

$browse = GUICtrlCreateButton("Browse Letter Content", 50, 245, 200)
GUICtrlSetTip (-1, "Opens the chronological record of letter content", "Letter Browser")

I've tried GUICtrlSetOnEvent($browse, "browse") but it loses focus as soon as the user starts the data entry.

Regards,

William

Edited by saywell

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Put $BS_DEFPUSHBUTTON as style for the button and in the function check if the input is 6 characters long.

[edit] for the input, you can set directly GUICtrlSetLimit($hInputID, 6)

Edited by taietel

Share this post


Link to post
Share on other sites

Thanks, Taitel - just what I needed. In fact, I can keep the input box size limit as well, without it affecting anything.

I keep discovering new and useful styles...

Regards,

William

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0