LucaMs Expert Licensed User Longtime User May 2, 2014 #1 I've looked everywhere, on the site and on Web, but I can not find a way to get the LostFocus (HasFocus = False) when the view that gets the focus has not an editable text, such as buttons, imageviews, ...
I've looked everywhere, on the site and on Web, but I can not find a way to get the LostFocus (HasFocus = False) when the view that gets the focus has not an editable text, such as buttons, imageviews, ...
stevel05 Expert Licensed User Longtime User May 2, 2014 #2 Have you tried the Reflection library and the SetOnFocusListener? Upvote 0
LucaMs Expert Licensed User Longtime User May 2, 2014 #3 Yes, I remember and found your post, Steve. But there are two problems: 1) The button is in the Pressed state 2) the button does not get the click, it must be pressed twice Upvote 0
Yes, I remember and found your post, Steve. But there are two problems: 1) The button is in the Pressed state 2) the button does not get the click, it must be pressed twice
stevel05 Expert Licensed User Longtime User May 2, 2014 #4 A button wouldn't normally take the focus, so if you make it focusable, the first click is consumed by the focus. Can you explain your intended usage, there may be an other way to achieve what you're after. Upvote 0
A button wouldn't normally take the focus, so if you make it focusable, the first click is consumed by the focus. Can you explain your intended usage, there may be an other way to achieve what you're after.
LucaMs Expert Licensed User Longtime User May 2, 2014 #5 The feature that I would get is simple, in theory . Let's say I have a EditText; the user enters text and then press the OK button. It is obvious that I could check the contents entered in the EditText inside the btnOK_Click event, but it is just an example to say that when the user presses OK, the event EditText_FocusChanged does not fire. Upvote 0
The feature that I would get is simple, in theory . Let's say I have a EditText; the user enters text and then press the OK button. It is obvious that I could check the contents entered in the EditText inside the btnOK_Click event, but it is just an example to say that when the user presses OK, the event EditText_FocusChanged does not fire.
thedesolatesoul Expert Licensed User Longtime User May 2, 2014 #6 Isnt that because the Edit text still has focus even on the button click? The button wouldnt normally take focus. Upvote 0
Isnt that because the Edit text still has focus even on the button click? The button wouldnt normally take focus.
stevel05 Expert Licensed User Longtime User May 2, 2014 #7 Where does the Focus go once OK is pressed? Upvote 0
stevel05 Expert Licensed User Longtime User May 2, 2014 #8 thedesolatesoul said: Isnt that because the Edit text still has focus even on the button click? The button wouldnt normally take focus. Click to expand... Yes, that's here I was going Upvote 0
thedesolatesoul said: Isnt that because the Edit text still has focus even on the button click? The button wouldnt normally take focus. Click to expand... Yes, that's here I was going
thedesolatesoul Expert Licensed User Longtime User May 2, 2014 #9 stevel05 said: Yes, that's here I was going Click to expand... I know Upvote 0
LucaMs Expert Licensed User Longtime User May 2, 2014 #10 Code: Private Sub TextBox1_LostFocus(sender As Object, e As System.EventArgs) Handles TextBox1.LostFocus If TextBox1.Text.Length = 0 Then MessageBox.Show("Invalid value") TextBox1.Focus() End If End Sub Upvote 0
Code: Private Sub TextBox1_LostFocus(sender As Object, e As System.EventArgs) Handles TextBox1.LostFocus If TextBox1.Text.Length = 0 Then MessageBox.Show("Invalid value") TextBox1.Focus() End If End Sub
stevel05 Expert Licensed User Longtime User May 2, 2014 #11 As thedesolatesoul said, pressing the OK button in an edittext doesn't necessarily move the focus, unless there is another focusable view for it to go to and you haven't set force done on the keyboard. Upvote 0
As thedesolatesoul said, pressing the OK button in an edittext doesn't necessarily move the focus, unless there is another focusable view for it to go to and you haven't set force done on the keyboard.
thedesolatesoul Expert Licensed User Longtime User May 2, 2014 #12 One trick is to keep an edittext off screen, and request focus to it. Upvote 0
LucaMs Expert Licensed User Longtime User May 2, 2014 #13 thedesolatesoul said: One trick is to keep an edittext off screen, and request focus to it. Click to expand... From? So I need to call xxx_request_focus inside the button_click event (and in all views for each EditText). In this case, you might as well write: EditText1_FocusChanged (True) In VB.Net, buttons receive focus, same as other not editable controls Upvote 0
thedesolatesoul said: One trick is to keep an edittext off screen, and request focus to it. Click to expand... From? So I need to call xxx_request_focus inside the button_click event (and in all views for each EditText). In this case, you might as well write: EditText1_FocusChanged (True) In VB.Net, buttons receive focus, same as other not editable controls
stevel05 Expert Licensed User Longtime User May 2, 2014 #14 If you want the buttons to be focusable you can set it using JavaObject: Code: DIm JO AS JavaObject = Button1 JO.RunMethod("setFocusable",Array As Object(True)) Or Code: DIm JO AS JavaObject = Button1 JO.RunMethod("setFocusableInTouchMode",Array As Object(True)) In this case, you might as well write: EditText1_FocusChanged (True) Click to expand... You'd probably be better off using the TextChanged event Upvote 0
If you want the buttons to be focusable you can set it using JavaObject: Code: DIm JO AS JavaObject = Button1 JO.RunMethod("setFocusable",Array As Object(True)) Or Code: DIm JO AS JavaObject = Button1 JO.RunMethod("setFocusableInTouchMode",Array As Object(True)) In this case, you might as well write: EditText1_FocusChanged (True) Click to expand... You'd probably be better off using the TextChanged event
stevel05 Expert Licensed User Longtime User May 2, 2014 #16 1) the button is in the focused state, it can have a different graphic (Which may be the same as pressed by default because buttons are not normally focusable) but you can change it using a statelistdrawable if you really want to. 2) see #4 Upvote 0
1) the button is in the focused state, it can have a different graphic (Which may be the same as pressed by default because buttons are not normally focusable) but you can change it using a statelistdrawable if you really want to. 2) see #4
LucaMs Expert Licensed User Longtime User May 2, 2014 #17 Please, try to develop a small app which behaves like this in VB.Net Attachments FocusTest.zip FocusTest.zip 6.7 KB · Views: 549 Upvote 0
stevel05 Expert Licensed User Longtime User May 2, 2014 #18 Try this one. Attachments LMS.zip LMS.zip 7.2 KB · Views: 552 Upvote 0
LucaMs Expert Licensed User Longtime User May 2, 2014 #19 Same as #13 Attachments LMS2.zip LMS2.zip 11.3 KB · Views: 575 Upvote 0
LucaMs Expert Licensed User Longtime User May 2, 2014 #20 I'm sorry, thanks anyway for the attached file, Steve Upvote 0