TreeNodeEvents: OnShowMenuItem

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: TreeNodeEvents: OnShowMenuItem

by Teknojnky » Thu Jan 24, 2008 1:53 pm

Bex wrote:Would it be possible to get a OnShowTreeMenu event to easier show/hide custom menus?
This was the purpose I was trying to figure out how to use it for, but it appears that isn't really the best way either..
Also OnShowMenu_Pop_NP, OnShowMenu_Pop_NP_MainWindow, OnShowMenu_Pop_TrackList, would be nice for the same reason.

The workaround with OnChangedSelection is a bit shaky!

Please!
Agreed! And I will have to investigate this OnChangedSelection workaround in the meantime! :o

by Bex » Thu Jan 24, 2008 1:48 pm

Thanks for the explanation. I've wondered a long time what the purpose was.

Would it be possible to get a OnShowTreeMenu event to easier show/hide custom menus?
Also OnShowMenu_Pop_NP, OnShowMenu_Pop_NP_MainWindow, OnShowMenu_Pop_TrackList, would be nice for the same reason.

The workaround with OnChangedSelection is a bit shaky!

Please!

by Teknojnky » Thu Jan 24, 2008 1:42 pm

Ok, thanks Jiri.. I'm still not understanding why the event is triggered 3 times tho.

by jiri » Thu Jan 24, 2008 1:17 pm

Yes, the documentation was a bit lacking there, so I have updated it with the exact way MediaMonkey currently uses the event. It should made clear the current behaviour.

Jiri

by Teknojnky » Thu Jan 24, 2008 12:20 pm

trixmoto wrote:The event is probably fired every time the menu appears (and thus the menu item is shown). I don't think you should be adding the menu item here, but if you really want to, you should check it doesn't already exist so that you only do it once, like this...
Well that is just the problem.. the menu is only shown once, but the event is fired 3 times...

trigger1 = left click (select node)
trigger2 & 3 = right click

if you right click the node without selecting it first, you still get 3 events triggered.

try it and see, create an event with a simple msgbox and then right click the tree and you will get the msgbox 3 times.

by trixmoto » Thu Jan 24, 2008 5:03 am

The event is probably fired every time the menu appears (and thus the menu item is shown). I don't think you should be adding the menu item here, but if you really want to, you should check it doesn't already exist so that you only do it once, like this...

Code: Select all

Sub TestMenu(node)
 Dim itm : Set itm = SDB.Objects("mnuTest")
  If itm Is Nothing Then
    Set SDB.Objects("mnuTest") = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree,0,0)
    SDB.Objects("mnuTest").Caption = "Test Menu"
  End If
End Sub

TreeNodeEvents: OnShowMenuItem

by Teknojnky » Wed Jan 23, 2008 11:02 pm

Since there doesnt seem to be any explaination @
http://www.mediamonkey.com/wiki/index.p ... owMenuItem

How is this event supposed to be used?

I'm getting 3 menu's when I tried to add 1... it seems to be firing 3 times...

Triggered once: when node left clicked (no menu displayed)

Triggered twice more: when node right clicked (menu displayed with 2x menu items)

so

Code: Select all

  Script.RegisterEvent TestNode, "OnShowMenuItem", "TestMenu"

Sub TestMenu(node)
 Set SDB.Objects("mnuTest") = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree,0,0)
 SDB.Objects("mnuTest").Caption = "Test Menu"
End Sub
The 'Test Menu' menu is added 3 times.

Is this a bug or how is this event supposed to work?

Top