B4J Question event handlers

westereng

Member
Licensed User
Hello!

Cant seem to find any info on this in the forums, so I'l ask then :)

In c# I have the ability to define a custom event like this:
C#:
public event EventHandler MyEvent;

and then subscribe to that event like this:
C#:
myObject.MyEvent += new EventHandler(myObject_MyEvent);

and then we can invoke it like this for example:
C#:
MyEvent?.Invoke(this, e);

Is there a similar concept in B4J?

/Ronny
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Find XUI Views.b4xlib in the internal libraries folder.
Unzip it. Yes, it is a simple zip file.

You will see many examples of custom views.
Example from B4XSwitch:
B4X:
'Declaration for IDE:
#Event: ValueChanged (Value As Boolean)

B4X:
'default XUI custom view template:
Public Sub Initialize (Callback As Object, EventName As String)
    mEventName = EventName
    mCallBack = Callback
End Sub

Event:
B4X:
CallSubDelayed2(mCallBack, mEventName & "_ValueChanged", mValue)
 
Upvote 0
Top