EddyW Member Licensed User Longtime User Nov 24, 2013 #1 We created a activatie with a tabhost on it and each tab has its own panel with objects. On one tab/panel we have 4 edittext and we want that the focus is on the 2th edittext of that tab/panel when the tab/panel is opened. in code i placed in the tabChanged the following code Code: Copy If TabHost1.CurrentTab = 6 Then EDT_WatermeterStand.RequestFocus End If When i debug it see that the focus goes tot he 2th edittext (EDT_WatermeterStand) and that there is no code running after it but the focus goes somehow back to the first edittext. It looks like there is a event behind the tabChanged that places the focus back to the first edittext. But we didnt write code for that, who knows in which event the focus is placed on the 1th edittext?
We created a activatie with a tabhost on it and each tab has its own panel with objects. On one tab/panel we have 4 edittext and we want that the focus is on the 2th edittext of that tab/panel when the tab/panel is opened. in code i placed in the tabChanged the following code Code: Copy If TabHost1.CurrentTab = 6 Then EDT_WatermeterStand.RequestFocus End If When i debug it see that the focus goes tot he 2th edittext (EDT_WatermeterStand) and that there is no code running after it but the focus goes somehow back to the first edittext. It looks like there is a event behind the tabChanged that places the focus back to the first edittext. But we didnt write code for that, who knows in which event the focus is placed on the 1th edittext?
Erel B4X founder Staff member Licensed User Longtime User Nov 24, 2013 #2 Try to use CallSubDelayed: Code: Copy Sub SetFocus(v As View) v.RequestFocus End Sub If TabHost1.CurrentTab = 6 Then CallSubDelayed2(Me, "SetFocus", EDT_WatermeterStand) End If Upvote 0
Try to use CallSubDelayed: Code: Copy Sub SetFocus(v As View) v.RequestFocus End Sub If TabHost1.CurrentTab = 6 Then CallSubDelayed2(Me, "SetFocus", EDT_WatermeterStand) End If
merlin2049er Well-Known Member Licensed User Longtime User Nov 25, 2013 #3 oh, I just posted the same thing today. Upvote 0
EddyW Member Licensed User Longtime User Nov 25, 2013 #4 Thanx Erel, Your idea worked Only i had to use Code: Copy Sub SetFocus() EDT_WatermeterStand.RequestFocus End Sub If TabHost1.CurrentTab = 6 Then CallSubDelayed(Me, "SetFocus") End If With your solution i get a signature mismatch but your solution is better. For now this works and when i have more time i figure out why it didnt work. Upvote 0
Thanx Erel, Your idea worked Only i had to use Code: Copy Sub SetFocus() EDT_WatermeterStand.RequestFocus End Sub If TabHost1.CurrentTab = 6 Then CallSubDelayed(Me, "SetFocus") End If With your solution i get a signature mismatch but your solution is better. For now this works and when i have more time i figure out why it didnt work.