View Issue Details

IDProjectCategoryView StatusLast Update
0019284MMW 5Extensions frameworkpublic2022-08-01 19:19
Reporterzvezdan Assigned To 
PrioritylowSeverityminorReproducibilityalways
Status feedbackResolutionreopened 
Summary0019284: 'focuschange' event handler of mediatree should have focused node as argument
Description'focuschange' event handler has one argument that gives a number, I don't have a slightest idea what it represents. It is different for every node, but I doubt that it is useful at all.

I suggest that 'focuschange' event handler have currently focused node as argument because that is the first thing that I would want to get in that event handler.
Steps To Reproduce    app.listen(window.currentTabControl.mediatree.controlClass.dataSource, 'focuschange', function (e) {
        var oSelNode = navUtils.getFocusedNode();
        console.log('oSelNode: ' + (oSelNode ? oSelNode.handlerID + ', title: "' + oSelNode.title + '", path: "' + oSelNode.dataSource.path + '", nodePath: ' + oSelNode.nodePath : '') + ', arg: ', (e), (oSelNode));
    });
TagsNo tags attached.
Fixed in build

Activities

Ludek

2022-07-26 15:56

developer   ~0068920

To access the focused node use dataSource.focusedNode like this:

var tree = window.currentTabControl.mediatree.controlClass;
app.listen(tree.dataSource, 'focuschange', function (e) {
        var oSelNode = tree.dataSource.focusedNode;
        console.log('oSelNode: ' + (oSelNode ? oSelNode.handlerID + ', title: "' + oSelNode.title + '", path: "' + oSelNode.dataSource.path + '", nodePath: ' + oSelNode.nodePath : '') + ', arg: ', (e), (oSelNode));
});

zvezdan

2022-07-26 17:11

updater   ~0068926

Since these event handlers execute asynchronously, it would be possible that the node that fired event is not the same as the one that you get with dataSource.focusedNode inside of that event handler, right? And maybe you just want to get info about the node that caused event, not the currently focused one.

I think that is the reason why many node events in MM4 had a node as an argument, including OnNodeFocused:
- OnCanEditNode (http://mediamonkey.com/wiki/ISDBTreeNodeEvents::OnCanEditNode)
- OnFillChildren (http://mediamonkey.com/wiki/ISDBTreeNodeEvents::OnFillChildren)
- OnFillTracks (http://mediamonkey.com/wiki/ISDBTreeNodeEvents::OnFillTracks)
- OnNodeFocused (http://mediamonkey.com/wiki/ISDBTreeNodeEvents::OnNodeFocused)
- and so on.

Ludek

2022-08-01 18:57

developer   ~0068956

This isn't asynchronous method. It's operated on the main JS/UI thread only.

So dataSource.focusedNode works to access the focused node.

zvezdan

2022-08-01 19:02

updater   ~0068957

It doesn't matter if it is asynchronous or not. What are you suggesting is just wasting of CPU cycles unnecessary. I could bet that your code which fires that and other node events already has a node object available that caused such event. Is that really so hard for you to add such new argument then?