seskindell Active Member Licensed User Longtime User Jun 28, 2011 #1 Is there a way I can determine which edittext control has focus when I press a button? Would I somehow use the .tag field of the edittext control to determine this? Thank you for any help you can provide. - Steve
Is there a way I can determine which edittext control has focus when I press a button? Would I somehow use the .tag field of the edittext control to determine this? Thank you for any help you can provide. - Steve
K kickaha Well-Known Member Licensed User Longtime User Jun 28, 2011 #2 Dim a global variable (lets call it EditFocus) as an EditText. Generate "FocusChanged" events for the EditTexts you want to monitor. In the FocusChanged event have these lines Code: If HasFocus Then EditFocus = Sender Else EditFocus = Null Then you have a pointer to the EditText that has the focus, it will be Null if none of them have focus. If the program doesnt use the EditText events for anything else you can set the event name to be the same on all the EditTexts and just have the one FocusChanged event. Upvote 0
Dim a global variable (lets call it EditFocus) as an EditText. Generate "FocusChanged" events for the EditTexts you want to monitor. In the FocusChanged event have these lines Code: If HasFocus Then EditFocus = Sender Else EditFocus = Null Then you have a pointer to the EditText that has the focus, it will be Null if none of them have focus. If the program doesnt use the EditText events for anything else you can set the event name to be the same on all the EditTexts and just have the one FocusChanged event.
A artiechappie Member Licensed User Longtime User Jan 13, 2012 #3 Hi, Can you elaborate on this as I have a similar problem - I have 6 EditText fields and I need to determine which one has focus? I am a recent "newbie" on this so any help would be appreciated. I have "Dim"ed the EditFocus as an EditText as you suggest but how do I pass the current EditText to the Event Handler and this is the Event Handler I created: Sub TextBox1_FocusChanged (HasFocus As Boolean) If HasFocus Then EditFocus = Sender Else EditFocus = Null End If End Sub Help please?? Many thanks in advance Upvote 0
Hi, Can you elaborate on this as I have a similar problem - I have 6 EditText fields and I need to determine which one has focus? I am a recent "newbie" on this so any help would be appreciated. I have "Dim"ed the EditFocus as an EditText as you suggest but how do I pass the current EditText to the Event Handler and this is the Event Handler I created: Sub TextBox1_FocusChanged (HasFocus As Boolean) If HasFocus Then EditFocus = Sender Else EditFocus = Null End If End Sub Help please?? Many thanks in advance
D David Riley Member Licensed User Longtime User Dec 17, 2014 #4 Code: Sub ButtonDelete_Click EditFocus.Text = "" End Sub Last edited: Dec 17, 2014 Upvote 0