View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006729 | MMW v4 | Framework: Scripts/Extensions | public | 2010-11-22 15:09 | 2013-09-22 18:18 |
Reporter | zvezdan | Assigned To | |||
Priority | high | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | reopened | ||
Fixed in Version | 4.0 | ||||
Summary | 0006729: ISDBTreeNodeEvents::OnNodeEdited and other events needed for nodes from Playlists branch | ||||
Description | We need a possibility to assign events to the nodes from Playlists branch. OnNodeEdited is particularly needed because we cannot know when user change some playlist title. Of course, in such case we need OnCanEditNode and OnNodeEditText as well, but OnNodeDragDrop and OnFillTracks also could be useful. | ||||
Steps To Reproduce | This code works with custom nodes outside of the Playlists branch, e.g. Magic Nodes or Play History & Stats, but not with playlist nodes: Option Explicit Sub OnStartup() Dim oMenuItem Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0) oMenuItem.Caption = "Assign event handlers to curent node" oMenuItem.UseScript = Script.ScriptPath oMenuItem.OnClickFunc = "AssignEvents" End Sub Sub AssignEvents(oItem) Dim oNode Set oNode = SDB.MainTree.CurrentNode If Not oNode Is Nothing Then Script.RegisterEvent oNode, "OnCanEditNode", "OnCanEditNode" Script.RegisterEvent oNode, "OnNodeEditText", "OnNodeEditText" Script.RegisterEvent oNode, "OnNodeEdited", "OnNodeEdited" End If End Sub Function OnCanEditNode(oNode) OnCanEditNode = True End Function Function OnNodeEditText(oNode) OnNodeEditText = oNode.Caption End Function Sub OnNodeEdited(oNode, sText) SDB.MessageBox sText, mtInformation, Array(mbOk) End Sub | ||||
Tags | No tags attached. | ||||
Fixed in build | 1345 | ||||
|
Looks like a bug in events handling for Playlist nodes, there doesn't seem to be any reason for it. |
|
Fixed in build 1345. Previously it worked only for custom nodes, it works for all nodes now. |
|
Verified 1348 |
|
1-st problem: OnNodeEdited works only until the parent node is collapsed. Steps to reproduce: - copy previous test script to Auto folder and restart program; - select some playlist node; - choose "Assign event handlers to curent node" from Edit menu; - rename the same playlist node -> you will get message box; - collapse its parent node and expand it again; - rename the same playlist node -> you will not get the message box. That problem could be avoided if we could register OnNodeEdited event handler on each expand of the parent node, but unfortunately we have the 2-nd problem: it is not possible to register OnFillChildren event handler to playlist nodes (I tried also OnFillTracksFunct which also doesn't work). Here is new test script: Option Explicit Sub OnStartup() Dim oMenuItem Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree, 0, 0) oMenuItem.Caption = "Assign OnFillChildren event handler to current node" oMenuItem.UseScript = Script.ScriptPath oMenuItem.OnClickFunc = "Test" End Sub Sub Test(oItem) Dim oNode Set oNode = SDB.MainTree.CurrentNode If Not oNode Is Nothing Then oNode.UseScript = Script.ScriptPath oNode.OnFillChildren = "OnFillChildren" End If End Sub Sub OnFillChildren(oNode) SDB.MessageBox oNode.Caption, mtInformation, Array(mbOk) End Sub As with the previous test script, this script works fine with custom nodes, but not with playlist nodes. I didn't try OnDragDrop event handler, but I need it to work with playlist nodes as well. Also, I want to register OnFillChildren event handler to Playlists node. |
|
I'm confirming this by using new Zvezdan script. |
|
One more problem/inconsistency with the current implementation of OnNodeEdited event for playlist nodes is that oNode.Caption gives the new caption (after renaming node), while for custom nodes (e.g. Magic Nodes) oNode.Caption is the old caption (before modification), where oNode is the first argument of the event handler. Here is a slightly modified first script: Option Explicit Sub OnStartup() Dim oMenuItem Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0) oMenuItem.Caption = "Assign event handlers to curent node" oMenuItem.UseScript = Script.ScriptPath oMenuItem.OnClickFunc = "AssignEvents" End Sub Sub AssignEvents(oItem) Dim oNode Set oNode = SDB.MainTree.CurrentNode If Not oNode Is Nothing Then Script.RegisterEvent oNode, "OnCanEditNode", "OnCanEditNode" Script.RegisterEvent oNode, "OnNodeEditText", "OnNodeEditText" Script.RegisterEvent oNode, "OnNodeEdited", "OnNodeEdited" End If End Sub Function OnCanEditNode(oNode) OnCanEditNode = True End Function Function OnNodeEditText(oNode) OnNodeEditText = oNode.Caption End Function Sub OnNodeEdited(oNode, sText) SDB.MessageBox oNode.Caption & " -> " & sText, mtInformation, Array(mbOk) End Sub By the way, I tried OnNodeDragDrop and it also doesn't work with playlist nodes. |