B4J Question B4xComboBox: is SelectedIndexChanged mandatory?

udg

Expert
Licensed User
Hi all,
today I'm experimenting with the XUI Views lib (1.87) and received the following error:

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Sub xcbcateg_selectedindexchanged was not found.

I don't need to track each index change event so I don't add what the error clearly indicates. Is it a "bug" (no check in the lib whether the method exist before calling it), is it a requisite (having that sub in my code) or whatever?
 

GuyBooth

Active Member
Licensed User
But having the event sub in the code prevents the error.
This is not normal behaviour, if we had to do this for every unused event our code would be crawling with unfilled subs.
Sounds like a bug to me, and definitely undesirable.
 

LucaMs

Expert
Licensed User
Is it a "bug" (no check in the lib whether the method exist before calling it)
Simply add the check to the class module.

[For newbies - replace the RaiseEvent routine with:
B4X:
Private Sub RaiseEvent
   If SubExists(mCallBack, mEventName & "_SelectedIndexChanged") Then
       CallSub2(mCallBack, mEventName & "_SelectedIndexChanged", getSelectedIndex)
   End If
End Sub
]
 
Last edited:
Top