First off a massive thank you for Erel in developing B4i which is in every way an improvement on the previous tool we were using. I've just been going through the tutorials and putting a few projects together and have a quick query regarding event handling in a class.
I have created a class which I'm using to hold a configurable panel (to hold a mix of views based on the input parameters). I've stripped back all the code to something very simple. Here is the relevant code:-
My problem is that whilst the views etc are rendered fine, when I click on the panel, I don't get the log message, but instead get this code:-
"Event target instance was released: btn_click"
However, if I remove the Sub PanelButton_Click completely, then it just closes with no log entry at all.
Sure it will be a simple explanation but I'm looking to understand why this isn't working as expected. Do I need to move the call into another module?
Many thanks!
I have created a class which I'm using to hold a configurable panel (to hold a mix of views based on the input parameters). I've stripped back all the code to something very simple. Here is the relevant code:-
B4X:
'Class module
Sub Class_Globals
Dim pnl As Panel
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(text As String, x As Int, y As Int, size As Int)
pnl.Initialize("PanelButton")
End Sub
Sub render As Panel
Return pnl
End Sub
Sub PanelButton_Click
Log("PanelButton was Clicked")
End Sub
My problem is that whilst the views etc are rendered fine, when I click on the panel, I don't get the log message, but instead get this code:-
"Event target instance was released: btn_click"
However, if I remove the Sub PanelButton_Click completely, then it just closes with no log entry at all.
Sure it will be a simple explanation but I'm looking to understand why this isn't working as expected. Do I need to move the call into another module?
Many thanks!
Last edited: