B4J Question B4xComboBox: is SelectedIndexChanged mandatory?

udg

Expert
Licensed User
Longtime 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?
 

DonManfred

Expert
Licensed User
Longtime User
Just add the event. You can leave the sub "empty" if you do not need it.
But having the event sub in the code prevents the error.
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime 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.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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:
Upvote 0
Top