iOS Question Picker_click event not firing

Moncai

Member
Licensed User
Longtime User
Hi, I'm using B4i 4.81 with hosted builder. My client wants to simply swipe then touch to select something. However, the Picker view does not seem to fire the click event. Sample code below (Layout Page1 just has Picker1 on it). Thanks in advance for the help!

B4X:
Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'Public variables can be accessed from all modules.
	Public App As Application
	Public NavControl As NavigationController
	Private Page1 As Page

	Private Picker1 As Picker
End Sub

Private Sub Application_Start (Nav As NavigationController)
	'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
	NavControl = Nav
	Page1.Initialize("Page1")
	Page1.Title = "Page 1"
	Page1.RootPanel.Color = Colors.White
	Page1.RootPanel.LoadLayout("Page1")
	NavControl.ShowPage(Page1)
	
	Dim items As List
	items.Initialize
	items.Add("Apple")
	items.Add("Pear")
	items.Add("Orange")
	Picker1.SetItems(0, items)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)	
End Sub

Private Sub Application_Background	
End Sub

Sub Picker1_Click
	Dim thing As String = Picker1.GetSelectedItem(0)
	Msgbox("You picked " & thing, "Success!")
End Sub
 

tufanv

Expert
Licensed User
Longtime User
Hi, I'm using B4i 4.81 with hosted builder. My client wants to simply swipe then touch to select something. However, the Picker view does not seem to fire the click event. Sample code below (Layout Page1 just has Picker1 on it). Thanks in advance for the help!

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private Picker1 As Picker
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    Page1.RootPanel.LoadLayout("Page1")
    NavControl.ShowPage(Page1)
   
    Dim items As List
    items.Initialize
    items.Add("Apple")
    items.Add("Pear")
    items.Add("Orange")
    Picker1.SetItems(0, items)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)   
End Sub

Private Sub Application_Background   
End Sub

Sub Picker1_Click
    Dim thing As String = Picker1.GetSelectedItem(0)
    Msgbox("You picked " & thing, "Success!")
End Sub
You have to use picker_itemselected for this not picker_click
 
Upvote 0

Moncai

Member
Licensed User
Longtime User
You have to use picker_itemselected for this not picker_click
Hi tufanv, I tried your "solution", but this fires upon just swiping. My customer explicitly wants to first swipe to the desired item at his leisure, then tap (click) to confirm. He has assured me this works in other iOS apps he uses. So I'm still hoping for a fix or workaround!
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
The click event appears in all views as they all inherit from the same base class. You shouldn't use it in this case.

You can probably add a click or tap event with GestureRecognizer library.
Hi tufanv, I tried your "solution", but this fires upon just swiping. My customer explicitly wants to first swipe to the desired item at his leisure, then tap (click) to confirm. He has assured me this works in other iOS apps he uses. So I'm still hoping for a fix or workaround!
or a button to confirm maybe after selecting the picker item.
 
Upvote 0
Top