View Issue Details

IDProjectCategoryView StatusLast Update
0006729MMW v4Framework: Scripts/Extensionspublic2013-09-22 18:18
Reporterzvezdan Assigned To 
PriorityhighSeverityminorReproducibilityalways
Status assignedResolutionreopened 
Fixed in Version4.0 
Summary0006729: ISDBTreeNodeEvents::OnNodeEdited and other events needed for nodes from Playlists branch
DescriptionWe 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 ReproduceThis 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
TagsNo tags attached.
Fixed in build1345

Relationships

related to 0011489 new ISDBApplicationEvents::OnNodeFillChildren and OnNodeDragDrop events needed 
related to 0011491 new Ability to assign some indentifier to some playlists needed 

Activities

jiri

2010-11-24 14:46

administrator   ~0021455

Looks like a bug in events handling for Playlist nodes, there doesn't seem to be any reason for it.

Ludek

2011-01-20 16:07

developer   ~0022494

Fixed in build 1345.

Previously it worked only for custom nodes, it works for all nodes now.

peke

2011-02-13 21:12

developer   ~0023042

Verified 1348

zvezdan

2013-08-24 18:11

updater   ~0037256

Last edited: 2013-08-24 18:15

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.

peke

2013-08-25 01:57

developer   ~0037258

I'm confirming this by using new Zvezdan script.

zvezdan

2013-09-22 18:18

updater   ~0037635

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.