View Single Post
Old 16th December 2002, 07:42   #3
iPlayTheSpoons
Major Dude
 
iPlayTheSpoons's Avatar
 
Join Date: Aug 2001
Location: SJSU
Posts: 1,030
Send a message via AIM to iPlayTheSpoons
the reason for this thread was really to help you make your own stuff, to do stuff that wasnt easily done with a premade script (like frisbee monkey's...which are excelent). one thing that is wonderful in its customizability is the drop down list. in this ill show how to creat your very own. if youve ever used Mercury or my skin, you know how neat and functional these can be.

again ill start with one of my scripts from Scythe...and again it will help if youre familiar. i trimmed it down to isolate what we want to work with and here it is:

code:

//----------------------------------------------------------------------------------------------------------------
// thinger.m
//
// controls super cool thinger functions
//
// help from rpeterclark's dropdown example
//
//----------------------------------------------------------------------------------------------------------------

#include "../../../lib/std.mi"

Global Group ToggleGroup;
Global Button Toggle;
Global Layout ThingerLayout;
Global Container ThingerContainer;
Global PopupMenu ControlPopup;

System.onScriptLoaded() {

ThingerContainer = getContainer("thinger");
Layout ThingerLayout = ThingerContainer.getLayout("normal");

ToggleGroup = ThingerLayout.getObject("togglebutton");
Toggle = ToggleGroup.getObject("toggle");

ControlPopup = new PopupMenu;
ControlPopup.addCommand("Play", 1,0,0);
ControlPopup.addCommand("Stop", 2,0,0);
ControlPopup.addCommand("Pause", 3,0,0);
ControlPopup.addCommand("Next", 4,0,0);
ControlPopup.addCommand("Previous", 5,0,0);
ControlPopup.addCommand("Open Files", 6,0,0);

}




Toggle.onRightButtonDown(int a, int b) {
Int intSelection = ControlPopup.popAtMouse();
if (intSelection > 0) {
if (intSelection==1) {
system.play();
}
else if (intSelection==2) {
system.stop();
}
else if (intSelection==3) {
system.pause();
}
else if (intSelection==4) {
system.next();
}
else if (intSelection==5) {
system.previous();
}
else if (intSelection==6) {
system.eject();
}
}
Complete;
}


ill assume youve read the last thing and know what the basics are. if so, this should be a breeze.

code:

ControlPopup = new PopupMenu;
ControlPopup.addCommand("Play", 1,0,0);
ControlPopup.addCommand("Stop", 2,0,0);
ControlPopup.addCommand("Pause", 3,0,0);
ControlPopup.addCommand("Next", 4,0,0);
ControlPopup.addCommand("Previous", 5,0,0);
ControlPopup.addCommand("Open Files", 6,0,0);


this here is where we tell winamp what we want our popup to look like. 'ControlPopup' is what I named the menu, you can make it whatever you like, just make sure it matches your Global definition! to add an option to our menu we use the 'addCommand()' function, and heres what the option inside the () mean: the first is what appears in the menu...easy enough. the second is which number on the list it will be, as well and the interger value its assigned. dont worry too much about what that means, just be ready to refer back to it--generally do it in the orderly way shown here, its easiest. the last two numbers are how it should appear when active/inactive(kinda like how theres a little mark next to the skin your using in the default menu). this can be a bit tricky to get to work right, but fortunately for us it doesnt matter in this case. by setting both to '0', there wont be any marks. this is more important for toggle stuff, which i might explain in more depth later.

code:

Toggle.onRightButtonDown(int a, int b) {
Int intSelection = ControlPopup.popAtMouse();
if (intSelection > 0) {
if (intSelection==1) {
system.play();
}
else if (intSelection==2) {
system.stop();
}
else if (intSelection==3) {
system.pause();
}
else if (intSelection==4) {
system.next();
}
else if (intSelection==5) {
system.previous();
}
else if (intSelection==6) {
system.eject();
}
}
Complete;
}


the heart of the code right here. according to this, when someone right clicks on the Toggle button it will cause the pop up to come down. this is pretty much a copy paste job, changing the names that need to be changed in the first part, and adding/subtracting else if statements as needed. for the if/else if statements, heres what they mean: the 'intSelection==x' part refers back to the int assignments i mentioned earlier. "Play" was assigned value 1, so if they select "Play" (or, you could say, 1), then it triggers the system.play() function (look in std.mi for funtions like that). the rest is pretty self explanitory. hope that does it for you.
iPlayTheSpoons is offline   Reply With Quote