View previous topic :: View next topic |
Author |
Message |
gbarnas KiXforms Regular

Joined: 07 Mar 2003 Posts: 41 Location: Mahwah, NJ
|
Posted: Tue Jan 12, 2010 4:03 am Post subject: Best way to determine input field? |
|
|
I have a form with about 10 data fields and a search button. The search button is the default button when the Enter key is pressed. Only 3 fields are enabled and searchable.
Is there an efficient way to determine which text field had focus when the enter key was pressed (or the search button was clicked)? The search parameters I define will depend upon which field had data entered.
I've been toying with an OnTextChanged action that sets a FieldID value. That works, but the action is called for each keystroke. Again, looking for a better way.
Thanks,
Glenn |
|
Back to top |
|
 |
eriqjaffe KiXforms Follower

Joined: 16 Aug 2004 Posts: 19 Location: Arlington Heights, IL, USA
|
Posted: Tue Jan 12, 2010 4:18 pm Post subject: |
|
|
You can use the "OnGotFocus" method.
Code: | $Form = $System.Form()
$Form.BackColor = 232,232,232
$Form.Height = 297
$Form.Text = "KiXforms Designer Template"
$TextBox1 = $Form.Controls.TextBox()
$TextBox1.Height = 20
$TextBox1.Left = 15
$TextBox1.Text = "TextBox1"
$TextBox1.Top = 15
$TextBox1.Width = 100
$TextBox1.OnGotFocus = "$Focus = 'TextBox1'"
$TextBox2 = $Form.Controls.TextBox()
$TextBox2.Height = 20
$TextBox2.Left = 15
$TextBox2.Text = "TextBox2"
$TextBox2.Top = 45
$TextBox2.Width = 100
$TextBox2.OnGotFocus = "$Focus = 'TextBox2'"
$TextBox3 = $Form.Controls.TextBox()
$TextBox3.Height = 20
$TextBox3.Left = 15
$TextBox3.Text = "TextBox3"
$TextBox3.Top = 75
$TextBox3.Width = 100
$TextBox3.OnGotFocus = "$Focus = 'TextBox3'"
$TextBox4 = $Form.Controls.TextBox()
$TextBox4.Height = 20
$TextBox4.Left = 15
$TextBox4.Text = "TextBox4"
$TextBox4.Top = 105
$TextBox4.Width = 100
$TextBox4.OnGotFocus = "$Focus = 'TextBox4'"
$Button1 = $Form.Controls.Button()
$Button1.Height = 23
$Button1.Left = 15
$Button1.Text = "Button1"
$Button1.Top = 135
$Button1.Width = 75
$Button1.OnClick = "$Focus" |
That's in kf classic, I'm not sure if kf.net has a different mechanism or not, though. |
|
Back to top |
|
 |
gbarnas KiXforms Regular

Joined: 07 Mar 2003 Posts: 41 Location: Mahwah, NJ
|
Posted: Wed Jan 13, 2010 9:57 pm Post subject: on track.. |
|
|
OK - thanks.. that's similar to what I'm doing. My searchable field definitions look like this: Code: | $txtEMPNO = $tabPAGE0.TextBox()
$txtEMPNO.Top = $Row + 15
$txtEMPNO.Left = $Col
$txtEMPNO.Width = $InpWidth
$txtEMPNO.Height = $InpHeight
$txtEMPNO.MultiLine = 0
$txtEMPNO.FontName = $InpFontN
$txtEMPNO.FontSize = $InpFontS
$txtEMPNO.OnTextChanged= '$MODIFIED=1'
$txtEMPNO.OnGotFocus= '$ACTIVEFIELD=2' | All fields set the modified flag, but only searchable fields set the ACTIVEFIELD flag, and identify not so much which field but what type of search parameter to set.
Loading data from the database clears the MODIFIED flag, so if a user clears the form or exits I can prompt them to save. Loading also sets a LOADED flag, which prevents triggering the search function if a user presses ENTER on a searchable field during entry or edit. If no data is found, the LOADED flag is set to prevent further searches and the system goes into Entry mode instead of Edit mode.
Glenn |
|
Back to top |
|
 |
|