View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0019284 | MMW 5 | Extensions framework | public | 2022-07-25 20:57 | 2022-08-01 19:19 |
Reporter | zvezdan | Assigned To | |||
Priority | low | Severity | minor | Reproducibility | always |
Status | feedback | Resolution | reopened | ||
Summary | 0019284: '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)); }); | ||||
Tags | No tags attached. | ||||
Fixed in build | |||||
|
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)); }); |
|
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. |
|
This isn't asynchronous method. It's operated on the main JS/UI thread only. So dataSource.focusedNode works to access the focused node. |
|
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? |