B4J Question [BANano] [SOLVED] How to define events for custom component?

Mashiane

Expert
Licensed User
Ola

I kindly request some help defining an event listener for this type of function..

B4X:
tree.on('collapse', function (e, node, id) {
         alert('collapse is fired.');
     });
My tree is currently a BANanoObject, which is fine, just need to figure out the next part of the equation

B4X:
tree.AddEventListener("collapse", xxx, xxx")
I'm dont have a clue because the event function above has three arguments, how do I convert such javascript code to banano code and also be able to get the node and id passed?

These are some of the other events that I'd like to add for the control.

B4X:
'tree.on('enable', function (e, node) {
    'alert(node.text() + ' is enabled.');
    '});
    'tree.on('disable', function (e, node) {
    'alert(node.text() + ' is disabled.');
    '});
    'tree.on('expand', function (e, node, id) {
    'alert('expand is fired.');
    '});
    'tree.on('select', function (e, node, id) {
    'alert('select is fired for node with id=' + id);
    '});
    'tree.on('unselect', function (e, node, id) {
    'alert('unselect is fired for node with id=' + id);
    '});
    'tree.on('checkboxChange', function (e, $node, record, state) {
    'alert('The new state of record ' + record.text + ' is ' + state);
    '});
Thanks
 
Last edited:

Kiffi

Well-Known Member
Licensed User
for Example for checkboxChange:
B4X:
' tree.on('checkboxChange', function (e, $node, record, state) { ...

Dim e, node, record, state As Map

tree.RunMethod("bind", Array("checkboxChange", Banano.Callback(mCallBack, mEventName & "_checkboxchange", Array(e, node, record, state))))
will call:
B4X:
Sub tv_CheckboxChange(e As Object, node As Object, record As Object, state As Object)
  ...
End Sub
 
Top