home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / soundCD_1.03.iso / players / WinAmp / winamp3_0-full.exe / Wacs / xml / library / queryedit.m < prev    next >
Text File  |  2002-07-22  |  2KB  |  88 lines

  1. #include <lib/std.mi>
  2.  
  3. Function sendQuery();
  4.  
  5. Global Group pgroup;
  6. Global Edit editfield;
  7.  
  8. Global string lastquery;
  9.  
  10. Global Button toggle;
  11. Global Boolean searchmode;
  12. Global String prevstr;
  13. Global QueryList qlist;
  14.  
  15. Function setSearchMode();
  16.  
  17. System.onScriptLoaded() {
  18.   // we only run in groups!
  19.   pgroup = getScriptGroup();
  20.   if (pgroup == NULL) {
  21.     messageBox("queryedit.maki can only run within a group", "Error", 0, "");
  22.     return;
  23.   }
  24.  
  25.   qlist = getScriptGroup().findObject("library.query.list");
  26.  
  27.   String id = getToken(getParam(), ";", 0);
  28.   editfield = pgroup.findObject(id);
  29.   if (editfield == NULL) {
  30.     messageBox("queryedit.maki cannot find the edit field (param 0 = " + id + ")", "Error", 0, "");
  31.   }
  32.  
  33.   toggle = pgroup.findObject("library.togglesearch");
  34.   searchmode = getPrivateInt("library", "mode", true);
  35.   prevstr = "";
  36.   setSearchMode();
  37. }
  38.  
  39. editfield.onEnter() {
  40.   sendQuery();
  41. }
  42.  
  43. editfield.onIdleEditUpdate() {
  44.   if (lastquery == editfield.getText()) return;
  45.   sendQuery();
  46. }
  47.  
  48. sendQuery() {
  49.   String id = getToken(getParam(), ";", 1);
  50.   GuiObject queryline = getScriptGroup().findObject(id);
  51.   lastquery = editfield.getText();
  52.   if (queryline != NULL) {
  53.     queryline.setXmlParam("auto", integerToString(searchmode));
  54.     queryline.setXmlParam("query", lastquery);
  55.   } else
  56.     messageBox("queryedit.maki cannot find the queryline field (param 1 = " + id + ")", "Error", 0, "");
  57. }
  58.  
  59. toggle.onLeftClick() {
  60.   Edit e = pgroup.findObject("library.query.edit");
  61.   String tmp = e.getText();
  62.   e.setText(prevstr);
  63.   prevstr = tmp;
  64.   searchmode = !searchmode;
  65.   setPrivateInt("library", "mode", searchmode);
  66.   setSearchMode();
  67. }
  68.  
  69. setSearchMode() {
  70.   Text t = pgroup.findObject("Search for");
  71.   if (searchmode == 0) {
  72.     t.setText("Query:");
  73.   } else if (searchmode == 1) {
  74.     t.setText("Search For:");
  75.   }
  76. }
  77.  
  78. System.onAccelerator(String action, String section, String key) {
  79.   if (key == "tab" && action == "jumper" && section == "pledit") {
  80.   }
  81. }
  82.  
  83. qlist.onResetQuery() {
  84.   editfield.setText("");
  85.   sendQuery();
  86. }
  87.  
  88.