Bug with Script.RegisterEvent and ISDBTreeNodeEvents?

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

ZvezdanD
Posts: 3271
Joined: Thu Jun 08, 2006 7:40 pm

Bug with Script.RegisterEvent and ISDBTreeNodeEvents?

Post by ZvezdanD »

If I use any of ISDBTreeNodeEvents (tried OnNodeEditText, OnShowMenuItem, OnExecMenuItem and OnNodeFocused), after that I could not expand nodes with OnFillChildren, neither I can fill tracklist window with OnFillTracksFunct nor edit node caption with OnEdited. Here is an example:

Code: Select all

Set newNode = SDB.MainTree.CreateNode
Script.RegisterEvent newNode, "OnNodeEditText", "CustomNodeEditText"
newNode.OnEdited = "EditCustomNodeRoot"
newNode.OnFillChildren = "FillCustomNode"
newNode.OnFillTracksFunct = "FillCustomLeaf"
SDB.MainTree.AddNode ParentNode, newNode, 3
Without Script.RegisterEvent line, other events (OnEdited, OnFillChildren and OnFillTracksFunct) work fine, but when I use that line - only such registered event (OnNodeEditText) works fine.

Did anybody used OnNodeEditText? Search of this forum didn't returned any result.
ZvezdanD
Posts: 3271
Joined: Thu Jun 08, 2006 7:40 pm

Post by ZvezdanD »

Well, I tried to replace all old definitions of event function with RegisterEvent:

Code: Select all

Set newNode = SDB.MainTree.CreateNode
Script.RegisterEvent newNode, "OnNodeEditText", "CustomNodeEditText"
Script.RegisterEvent newNode, "OnNodeDragDrop", "CustomDragDrop"
Script.RegisterEvent newNode, "OnNodeEdited", "EditCustomNodeRoot"
Script.RegisterEvent newNode, "OnFillChildren", "FillCustomNode"
Script.RegisterEvent newNode, "OnFillTracks", "FillCustomLeaf"
SDB.MainTree.AddNode ParentNode, newNode, 3
In that case only OnFillTracks and OnFillChildren events are invoked, but not OnNodeEditText, OnNodeEdited nor OnNodeDragDrop. With old event's definitions I have all events except of OnNodeEditText which is less problematic then this with RegisterEvent.
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

I didn't try to replicate your problem but you need to use:

Code: Select all

Script.RegisterEvent newNode, "OnCanEditNode", "OnCanEditSomeNode"
To make these work properly

Code: Select all

Script.RegisterEvent newNode, "OnNodeEditText", "CustomNodeEditText"
Script.RegisterEvent newNode, "OnNodeEdited", "EditCustomNodeRoot"
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
ZvezdanD
Posts: 3271
Joined: Thu Jun 08, 2006 7:40 pm

Post by ZvezdanD »

Bex wrote:I didn't try to replicate your problem but you need to use:

Code: Select all

Script.RegisterEvent newNode, "OnCanEditNode", "OnCanEditSomeNode"
You are great! It does the job. Big thanks!

Anyway, in my opinion this is senseless. If I already registered OnNodeEdited and other events for some node, this means that I want to use those events for that node. If I don't want to use those events anymore, I could use UnRegisterEvents, right? If someone really need to disable only those editing events without unregistering all events, then one could use this OnCanEditNode event, but only in that case - default behavior should be enabled events, not disabled. Old way for defining event functions is more logical to me.

Now, could you tell me how can I check if I registered some event for certain node, without defining some global variable or (even worse) some object? With old functions I could use something like this:

Code: Select all

If oTargetNode.OnDragDrop = "CustomDragDrop" Then
I think that OnCanEditNode should be a read/write property, not event.
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

I don't know how to do that but can't you change the logic to something like:

Code: Select all

Sub CustomDragDrop(Node)
   If Not something = True Then
     Exit Sub
   Else
    DragDrop Actions
End Sub
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
ZvezdanD
Posts: 3271
Joined: Thu Jun 08, 2006 7:40 pm

Post by ZvezdanD »

Eh, this is not as simple as it sounds. During drag&drop I needed to update several nested levels in one go, so I needed to check for each level if it is allowed for drag&drop. Never mind, I resolved that. Thanks again.
Post Reply