saywell Posted April 14, 2011 Share Posted April 14, 2011 (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 April 14, 2011 by saywell Link to comment Share on other sites More sharing options...
taietel Posted April 14, 2011 Share Posted April 14, 2011 (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 April 14, 2011 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
James Posted April 14, 2011 Share Posted April 14, 2011 As a crude way around this, you could use ControlFocus() but it's pretty bleh. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
saywell Posted April 14, 2011 Author Share Posted April 14, 2011 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now