View Issue Details

IDProjectCategoryView StatusLast Update
0005220MMW v4Framework: Scripts/Extensionspublic2009-06-05 15:14
ReporterTeknojunkyAssigned To 
PriorityimmediateSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.1 
Fixed in Version3.1 
Summary0005220: Node.Caption Fails to update immediately
DescriptionWhen attempting to dynamically set the caption for a user node, the text does not update until something causes the window to refresh (mouse over or app window active/inactive).

see code example, caption should update onplay, but does not unless window gets refreshed.

option explicit
  dim tree : set tree = sdb.maintree
  
  dim testnode : set testnode = tree.createnode

Sub OnStartup()

  
  testnode.caption = "test node"
  testnode.Visible = True
  
  tree.addnode tree.node_library, testnode, 1
  
  script.registerevent sdb, "OnPlay", "UpdateCaption"

End Sub


Sub UpdateCaption()
    testnode.Caption = "test node " &_
      " (" & SDB.Player.CurrentSong.ArtistName &_
      " - " & SDB.Player.CurrentSong.Title & " )"
  
End Sub
Additional Informationhttp://www.mediamonkey.com/forum/viewtopic.php?f=6&t=36123
TagsNo tags attached.
Fixed in build1222

Activities

jiri

2009-01-20 21:17

administrator   ~0016318

Fixed in build 1216.
 - Added SDBTree::Refresh method.

Teknojunky

2009-01-21 05:24

updater   ~0016330

Confirmed working, thanks!

Teknojunky

2009-01-29 20:12

updater   ~0016462

Last edited: 2009-01-29 20:36

Hi Jiri, I have created a small script to update the built in "Now Playing" node to include the player current song artist-title, however the sdb.maintree.refresh does not seem to be working for it (although it works for my other user added node).


edit:
Hmmm, now it seems to be working correctly. I don't think I changed anything other than restarted again.


edit2:
actually, it isn't working when I toggle it off/on.

code example

Sub OnStartup

  Do While Not SDB.IsRunning
    SDB.Tools.Sleep 100
    SDB.ProcessMessages
  Loop

  Dim mnu : Set mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View,1,-1)
  mnu.Caption = "Now Playing Node caption"
  mnu.Hint = "Show/Hide current artist - title on now playing node"
  mnu.UseScript = Script.ScriptPath
  mnu.OnClickFunc = "ToggleCaption"
' mnu.Shortcut = ""
  If SDB.IniFile.BoolValue("NowPlayingCaption","Enabled") Then
    mnu.Checked = True
    Script.RegisterEvent SDB, "OnPlay", "UpdateCaption"
  End If
  
End Sub


Sub ToggleCaption(obj)
  Dim Node
  If obj.Checked = True Then
    obj.Checked = False
    SDB.IniFile.BoolValue("NowPlayingCaption","Enabled") = False
    Set Node = SDB.MainTree.Node_NowPlaying
    Node.Caption = "Now Playing"
    SDB.MainTree.Refresh
    Script.UnregisterAllEvents
    Set Node = Nothing
  Else
    obj.Checked = True
    SDB.IniFile.BoolValue("NowPlayingCaption","Enabled") = True
    Script.RegisterEvent SDB, "OnPlay", "UpdateCaption"
    UpdateCaption
  End If
End Sub

Sub UpdateCaption()
' msgbox("update caption")
  Dim Node : Set Node = SDB.MainTree.Node_NowPlaying
  Node.Caption = "Now Playing (" &_
   SDB.Player.CurrentSong.ArtistName & " - " &_
   SDB.Player.CurrentSong.Title & ")"
  SDB.MainTree.Refresh
  
End Sub

Teknojunky

2009-01-29 20:47

updater   ~0016463

Last edited: 2009-01-29 21:01

actually, I think see what is happening..

if the standard now playing is the CURRENT node (meaning highlighted), the hightlight does not update the length of the newly updated string.

but if the now playing node is NOT selected, the text updates correctly.

to reproduce (with the above autoscript)
- select now playing node
- click view > toggle now playing caption
- note that the highlighted now playing text did not change, but if you mouse over it will then update


Now select a different node and repeat above, now playing caption updates correctly.

This happens also on custom user nodes, I just never noticed before now.

edit:
probably related to the above caption not resizing, the horizontal scroll bars also do not update correctly when caption text changes length.

jiri

2009-02-03 17:39

administrator   ~0016499

Fixed in build 1222.

peke

2009-06-05 15:14

developer   ~0018191

Verified 1250