Newbie wants to play with RadioButtons!

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

Moderators: Gurus, Addon Administrators

Just Guessing
Posts: 64
Joined: Mon Sep 03, 2012 12:06 pm

Newbie wants to play with RadioButtons!

Post by Just Guessing »

Hi folks.

I've been primitively banging code around for a long day and am not getting anywhere (because I don't actually know what I'm doing!). So, I am going to reach out for some aid from the educated talents here. I think what I'm after is simple, but if I can't find an example of a similar script by others, then I'm almost just guessing.

Dockable panel I'm trying to generate:

Two buttons (potentially several), when pressed writes specific tags "King" & "Kong" to the TEMPO field.
Beside these buttons is a RADIO BUTTON pair;
one when selected (by default) causes the King/Kong button to write to the CURRENTLY PLAYING song.
The other when selected causes the King/Kong button to write to any SELECTED songs.

I'm hung up at the radio button action - but its a key piece of the practicality I'm after.

--((And while I'm posting, can anyone recommend a vbs editor that assists in MediaMonkey oriented code? I tried Admin Script Editor; but it seems like the syntax/etc that it helps to craft is slightly off from what MediaMonkey needs to see. I intend to get good at this fast, as I've found several other powerful programs I'm using also have implemented this scripting aspect, and man does it change everything! I love it.))--

I've been working from this basic framework, which I post in case I'm making some error from the getgo. Thanks for taking an interest:

Code: Select all

Dim Mnu, Pnl, Lbl, Lbl2 
 
Sub OnStartup 
	Set UI = SDB.UI 
	Set Pnl = UI.NewDockablePersistentPanel("AddToTempo") 
	If Pnl.IsNew Then 
		Pnl.DockedTo = 3 
		Pnl.Common.Width = 250 
	End If 
	Pnl.Caption = "AddToTempo" 
	Script.RegisterEvent Pnl, "OnClose", "PnlClose" 
	 
	Set Lbl = UI.NewLabel(Pnl) 
	Lbl.Autosize = False 
	Lbl.Multiline = True 
	Lbl.Common.SetRect 10, 10, Pnl.Common.Width - 20, Pnl.Common.Height - 20 
	Lbl.Common.Anchors = 15  '1+2+4+8 

	' ----------------------buttons------------------------------
	Set Btn = UI.NewButton(Pnl) 
	Btn.Common.ControlName = "Btn" 
	Btn.Common.SetRect 9, 6, 34, 20 
	Btn.Caption = "KING"
	Script.RegisterEvent Btn.Common, "OnClick", "BtnClick" 
	
	Set Btn = UI.NewButton(Pnl) 
	Btn.Common.ControlName = "Btn" 
	Btn.Common.SetRect 9, 6, 34, 20 
	Btn.Caption = "KONG"
	Script.RegisterEvent Btn.Common, "OnClick", "BtnClick" 

	Dim RadioButton1 : Set RadioButton1 = SDB.UI.NewRadioButton(Pnl)
	RadioButton1.Caption = "Selected Music"
	RadioButton1.Common.SetRect 700, 3, 80, 17
	RadioButton1.Common.ControlName = "choose1" 			' not sure how to use this element
	Script.RegisterEvent RadioButton1.Common, "OnClick", "MyAction1"

	Dim RadioButton2 : Set RadioButton2 = SDB.UI.NewRadioButton(Pnl)
	RadioButton2.Caption = "Now Playing"
	RadioButton2.Checked = True
	RadioButton2.Common.SetRect 700, 23, 80, 17
	RadioButton2.Common.ControlName = "choose2"
	Script.RegisterEvent RadioButton2.Common, "OnClick", "MyAction2" 	  ' should this be    OnChange?
 
	' If Pnl.Common.ChildControl("Choose1").Checked Then 		  -- use this avenue?
		
	' ------------------------menu option-----------------
	Set Sep = SDB.UI.AddMenuItemSep(SDB.UI.Menu_View, 0, 0) 
	Set Mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View, 0, 0) 
	Mnu.Caption = "Add To Tempo" 
	Mnu.Shortcut = "Ctrl+Alt+Shift+3" 
	Mnu.Checked = Pnl.Common.Visible 
	Script.RegisterEvent Mnu, "OnClick", "ShowPanel" 
	Script.RegisterEvent SDB, "OnChangedSelection", "OnSelection" 
	
End Sub 
' -------------------------------panel actions ----------------------
Sub ShowPanel(Item) 
	Pnl.Common.Visible = Not Pnl.Common.Visible 
	Mnu.Checked = Pnl.Common.Visible 
End Sub 
 
Sub PnlClose(Item) 
	Mnu.Checked = False 
End Sub 
 
Sub OnSelection 
End Sub
' -------------------------------Button action ----------------------
'	                                                                        use OnClick action?
' Sub MyAction1(Control)
'   Dim objSongData
'   Set objSongData = SDB.Player.CurrentSong ' for now playing
' End Sub

' Sub MyAction2(Control)
'   Dim objSongData
'   Set objSongData = SDB.Player.CurrentSongList ' for selected  		- should be   SelectedSongList?
'   If objSongData.Count = 0 Then
'        Exit Sub
'   End If
' End Sub

Sub BtnClick(Btn) 
	Dim objSongData,  objSongList
	Set objSongList = SDB.NewSongList   
	Set objSongData = SDB.Player.CurrentSong 
	' 					Use what-if to get action?
	' If WHAT = WHAT Then                                       -cant figure out how to tool this
	'     Set objSongData = SDB.Player.CurrentSong 
	' End If
	' If WHAT = WHAT Then   
	'     Set objSongData = SDB.Player.CurrentSongList          -- should this be SelectedSongList?
	'	 If objSongData.Count = 0 Then
	'		 Exit Sub
	' End If
	
	' ----------------------------for multivalue TEMPO field -----------------
	objSongList.Add(objSongData)
	Dim StringTempo, StringNewTempo, StringAddTempo
	StringTempo = objSongData.Tempo
	StringAddTempo = "; " & Btn.Caption
	If InStr(StringTempo, Btn.Caption) = 0 Then
		StringNewTempo = StringTempo & StringAddTempo 
		objSongData.Tempo = StringNewTempo 
		objSonglist.UpdateAll           
	End If  
 
End Sub
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Newbie wants to play with RadioButtons!

Post by trixmoto »

Can you be more specific about what isn't working the way you want it to?

Personally I just use Notepad++, which gives me no real help whatsoever, which I like. Intellisense always annoys me, it slows me down because I can type quicker than I can select the item that I want.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Just Guessing
Posts: 64
Joined: Mon Sep 03, 2012 12:06 pm

Re: Newbie wants to play with RadioButtons!

Post by Just Guessing »

Hi.

Well thanks to examples posted by others, I can get lovely buttons in panels that write to my tags. Its great!

But I can't find any examples of:
- - - how to get 2 radio buttons to affect the option of writing these same tags, to 'selected' vs 'now playing'.

Without someone elses similar work to examine, its quite over my head, and several weeks of study out of reach. I've tried hard to find some other script that's along the same lines and I haven't come up with anything yet. (I will be doing the study! I just want to reach out for guidance, too, if its available.)
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Newbie wants to play with RadioButtons!

Post by trixmoto »

Current playing song... SDB.Player.CurrentSong

Currently selected song...SDB.SelectedSongList.Item(0)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Post Reply