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

Discussion in 'B4J Questions' started by Mashiane, Apr 21, 2019.

  1. Mashiane

    Mashiane Expert Licensed User

    Ola

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

    Code:
    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

    Code:
    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.

    Code:
    '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: Apr 23, 2019
    joulongleu likes this.
  2. Mashiane

    Mashiane Expert Licensed User

    @Kiffi , do you think you can advise on this issue please? Thanks
     
    joulongleu likes this.
  3. Kiffi

    Kiffi Well-Known Member Licensed User

    for Example for checkboxChange:
    Code:
    ' 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:
    Code:
    Sub tv_CheckboxChange(e As Object, node As Object, record As Object, state As Object)
      ...
    End Sub
     
    joulongleu and Mashiane like this.
  4. Mashiane

    Mashiane Expert Licensed User

    @Kiffi, thanks a million, everything is working perfectly.
     
    joulongleu likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice