TreeNode.OnShowMenuItem and OnExecMenuItem

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

TreeNode.OnShowMenuItem and OnExecMenuItem

Postby trixmoto » Mon Apr 19, 2010 5:25 pm

Has anyone tried using these yet? I can't seem to do anything with them. What I'm attempting to do is allow the user to right click and remove a node which has been added by my script. Anyone got any ideas?

The wiki says one of the values of ItemIndex is "4 .. Custom Remove - Does this tree node has its own handling of Remove command?" but how do you make the tree node handle the remove command?
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Re: TreeNode.OnShowMenuItem and OnExecMenuItem

Postby Bex » Mon Apr 19, 2010 5:33 pm

I tried to figure out how they worked a couple of years ago but with no success. Perhaps it's easiest to add your own remove menu+command? Or will that result in two remove menus?
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
Bex
 
Posts: 6268
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Re: TreeNode.OnShowMenuItem and OnExecMenuItem

Postby ZvezdanD » Mon Apr 19, 2010 5:57 pm

Yes, I tried it long time ago with Magic Nodes. If you take a look at its source code, you would find those lines commented. Those events work fine, but I dropped that idea because it wouldn't be consistent with the built-in Remove option which removes tracks from tracklist, not a node itself. For example, if you right-click on some album from the Album node and if you choose Remove option, it will remove tracks, not node. So, I added new Delete Magic Node option to the context menu and implemented my own code for removing MN nodes.
Magic Nodes 4.2 (2011-07-01) RegExp Find & Replace 4.3 (2011-07-06)  Invert Selection/Select None 1.5 (2012-02-04)  Export M3Us/Create Playlists for Child Nodes 3.6.1 (2012-01-09)  Expand Child Nodes/Expand All 1.1.1 (2012-02-13)  Event Logger 2.4.1 (2012-02-06)  Filtered Statistics Report 1.5.1 (2009-10-09)  Track Redirection & Synchronization 3.4 (2012-10-08)  Restore/Synchronize Database 3.1.1 (2012-05-31)  Find Currently Playing Track 1.2 (2012-02-14)  Queue List 1.2 (2012-02-06)  Add to Library on Play 1.0 (2010-10-20)  Tree Report for Child Nodes 1.1 (2010-11-04)  Update Location of Files in Database 1.3.3 (2012-06-12)  Inherit Child Playlists 1.0 (2012-01-16)
Add Currently Playing/Selected Track(s) to Playlist 1.1.1 (2012-02-06)
ZvezdanD
 
Posts: 2590
Joined: Thu Jun 08, 2006 7:40 pm

Re: TreeNode.OnShowMenuItem and OnExecMenuItem

Postby trixmoto » Tue Apr 20, 2010 4:52 am

Ok thanks, I'll go with that approach then. Would still be nice to understand how it's supposed to work though! :)
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Re: TreeNode.OnShowMenuItem and OnExecMenuItem

Postby ZvezdanD » Tue Apr 20, 2010 6:58 am

Usage is really simple. First, you need to register those events for your custom node:
Code: Select all
        Script.RegisterEvent oCustomNode, "OnExecMenuItem", "OnExecMenuItem"
        Script.RegisterEvent oCustomNode, "OnShowMenuItem", "OnShowMenuItem"


Then you should enable the Remove option in the context menu for that node:
Code: Select all
Function OnShowMenuItem(iItemIndex)
    Select Case iItemIndex
    Case 5
        OnShowMenuItem = True
    Case Else
        OnShowMenuItem = False
    End Select
End Function


Then you should provide a code for removing that node when user click on the Remove option:
Code: Select all
Function OnExecMenuItem(iItemIndex)
    If iItemIndex = 5 Then
        If Not SDB.MainTree.CurrentNode Is Nothing Then
            ' My own function for removing node:
            DeleteNodeWithMask SDB.MainTree.CurrentNode.CustomNodeID
            ' It could contain just:
            ' SDB.MainTree.RemoveNode SDB.MainTree.CurrentNode
        End If
        OnExecMenuItem = True
    Else
        OnExecMenuItem = False
    End If
End Function
Magic Nodes 4.2 (2011-07-01) RegExp Find & Replace 4.3 (2011-07-06)  Invert Selection/Select None 1.5 (2012-02-04)  Export M3Us/Create Playlists for Child Nodes 3.6.1 (2012-01-09)  Expand Child Nodes/Expand All 1.1.1 (2012-02-13)  Event Logger 2.4.1 (2012-02-06)  Filtered Statistics Report 1.5.1 (2009-10-09)  Track Redirection & Synchronization 3.4 (2012-10-08)  Restore/Synchronize Database 3.1.1 (2012-05-31)  Find Currently Playing Track 1.2 (2012-02-14)  Queue List 1.2 (2012-02-06)  Add to Library on Play 1.0 (2010-10-20)  Tree Report for Child Nodes 1.1 (2010-11-04)  Update Location of Files in Database 1.3.3 (2012-06-12)  Inherit Child Playlists 1.0 (2012-01-16)
Add Currently Playing/Selected Track(s) to Playlist 1.1.1 (2012-02-06)
ZvezdanD
 
Posts: 2590
Joined: Thu Jun 08, 2006 7:40 pm

Re: TreeNode.OnShowMenuItem and OnExecMenuItem

Postby trixmoto » Tue Apr 20, 2010 10:53 am

I tried something like that last night but I couldn't get it to work. :-? I'll have to have another look tonight.
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Re: TreeNode.OnShowMenuItem and OnExecMenuItem

Postby trixmoto » Tue Apr 20, 2010 1:22 pm

Oooops! :oops: I had a node and a subnode and due to some iffy cut/pasting I was registering the events to the node instead of the subnode! :lol:
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK


Return to Addons developer forum

Who is online

Users browsing this forum: No registered users and 1 guest