Script help

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Script help

by trixmoto » Mon Oct 23, 2006 10:42 am

I feared it might! :-?

by Bex » Mon Oct 23, 2006 9:11 am

Ok guys, I can confirm that it is a very bad idea to assign a NodeType value to a custom nodes since it gives strange unwanted behaviour to the node...

by Bex » Mon Oct 23, 2006 7:05 am

Yes, it's probably better to use CustomNodeID on custom nodes but to id regular nodes you must use NodeType because they dont have a CustomNodeID, do they?

I've already studied your great map of NodeType values (along with the other helpfull tips on the script resource page) but thanks anyway! :D


Another thing. Has any of you used OnNodeDragDrop in a script which I can study?
Pablo has used it in Magic Nodes but I have problems to understand how that script is working :oops:
I still have a lot to learn with vbscript, as you can see in my messy codes, so I greatfully receive any tips/help I can get! :D

by Steegy » Mon Oct 23, 2006 6:13 am

Trixmoto is right. Maybe CustomNodeID is better.

Here's how NodeType is used: http://home.tiscali.be/ruben.castelein/ ... eTypes.txt (e.g. good to recognise Custom Nodes).
So if you use NodeType, make sure it's > 255.

by trixmoto » Mon Oct 23, 2006 5:47 am

It's not been released because it is a custom script someone has requested, and it's not finished yet.

It's probably ok to use NodeType, but as this value is used internally it's not something I'd change myself, as I don't know what internall it is used for.

by Bex » Mon Oct 23, 2006 5:07 am

Thanks guys!
But if you create a popup menu item which you want to display in a regular node then you need to use NodeType, don't you? (e.g. psyxonovas merge playlists)
Must have missed that script with the toolbar workaround, which is it?

by trixmoto » Mon Oct 23, 2006 3:38 am

I would recommend using CustomNodeId instead of NodeType as the custom properties are designed for this kind of thing. Great workaround! I've used this method with toolbar buttons but it never occurred to me to try it with popup menu items! :)

by Steegy » Sun Oct 22, 2006 7:43 pm

If that works (it looks good), then we must have overlooked the fact that this new event OnChangedSelection solves this problem :lol: :oops:

by Bex » Sun Oct 22, 2006 6:21 pm

I actually solved it! :D :D
At least I think I did. I involved the OnChangedSelection event to change the visibility of the menu.

It seems to work just fine. Do anyone see any potential errors/drawbacks?

Here's what I did:

Code: Select all

' Example code to on how make own menu entries Visible/Not Visible based on what node is selected
Sub onstartup 
  Dim Tree : Set Tree = SDB.MainTree
  Dim Node : Set Node = Tree.CreateNode
  Node.Caption = "Test Node"
  Node.IconIndex = 47
  Node.CustomNodeId = 1111 'Must not already exist
  Tree.AddNode Tree.Node_Library, Node, 1
  
' Add a menu entry to the Pop tree menu in main window
  Dim mnu
  Set Mnu = SDB.UI.AddMenuItem( SDB.UI.Menu_Pop_Tree , -1, 1)
  Mnu.Caption = "&Test Menu"
  Mnu.IconIndex = 9
  Mnu.UseScript=Script.ScriptPath
  
  Script.RegisterEvent SDB, "OnChangedSelection", "FixMnuVisible"
  
  SDB.Objects("Mnu") = Mnu
  SDB.Objects("Mnu").Visible = False
end sub

sub FixMnuVisible
  dim myNode
  Set myNode = SDB.MainTree.CurrentNode
  if myNode.CustomNodeId = 1111 Then
     SDB.Objects("Mnu").Visible = True
  else
     SDB.Objects("Mnu").Visible = False
  end if
End sub
Edit: code edited

by Bex » Sun Oct 22, 2006 4:39 pm

Ok thanks Steegy. I hope Jiri add this function in next version.

by Steegy » Sun Oct 22, 2006 4:17 pm

Bex wrote:...I want to add SDB.UI.Menu_Pop_Tree menu item which only is enabled if my new node (or its subnode) is selected....
You're not the only scripter wanting this (I officially know 4): http://www.mediamonkey.com/forum/viewto ... 8404#38404

I'll let an other scripter answer your 2nd question as I can't help very much (I try the events I think I need before using them in a script).

Cheers
Steegy

Script help

by Bex » Sun Oct 22, 2006 11:49 am

Hi,

I'm working on a script which creates a node. I want to add SDB.UI.Menu_Pop_Tree menu item which only is enabled if my new node (or its subnode) is selected. Is that possible? If it is, how do i do it?

I also want to add a Menu_Pop_TrackList menu which only is enabled if tracks from my nodes above is selected. Gues it's kind of same solution to the problem above.

I have searched the forum but without finding a solution...


I also wonder what these TreeNodeEvents are supposed to be used to:
- OnExecMenuItem
- OnExecTrackMenuItem
- OnShowMenuItem
- OnShowTrackMenuItem
They all have ItemIndex as parameter.
But what ItemIndex?
Actually, what is ItemIndex?


Help!
/Bex

Top