B4J Question PreferencesDialog requestfocus

stevetheframe

Member
Licensed User
Longtime User
Is it possible to requestfocus of a PreferencesDialog field?
So when the Dialog appears the user can just get on and fill it in without having to play around with the mouse to find where the cursor has gone.
 

stevetheframe

Member
Licensed User
Longtime User
Assuming that the 6th item is a text item:
B4X:
Dim sf As Object = p.ShowDialog(Data, "OK", "CANCEL")
Sleep(0)
p.CustomListView1.GetPanel(5).GetView(0).GetView(0).RequestFocus 'change 5 to whichever index  you need
Wait For (sf) Complete (Result As Int)

Thank you, but I can't get this to work.
I want the first item in the PreferenceDialog to get focus. So I changed your example to p.customlistview1.getpanel(0) and got an Index out of bounds exception.
So, in order to more closely follow your example I added line 14 (Dim sf as ......) and commented out my original line 18 (wait for (prefJob .....). Now sf is highlighted as a syntax error on line 14


B4X:
Dim mpJob As Map
        mpJob.Initialize

        Dim prefJob As PreferencesDialog
        prefJob.Initialize(Main.MainForm.RootPane,"Job details",420,260)
        If cboMounts.SelectedItem = "None" Then
            prefJob.LoadFromJson(File.ReadString(File.DirAssets,"JobNoMount.json"))
        Else
            prefJob.LoadFromJson(File.ReadString(File.DirAssets,"Job.json"))
        End If
        prefJob.TextColor = xui.Color_Blue
        prefJob.ItemsBackgroundColor = xui.Color_RGB(192,192,192)
        
        Dim sf As Object = prefJob.ShowDialog(mpJob,"ok","Cancel)
        Sleep(0)
        prefJob.CustomListView1.GetPanel(0).GetView(0).GetView(0).RequestFocus
        Wait For (sf) complete (Result As Int)
        'wait for (prefJob.ShowDialog(mpJob,"Ok","Cancel")) Complete (Result As Int)
        If Result = xui.DialogResponse_Positive Then
 
Upvote 0
Top