mardi 8 février 2011

How to build your own context menu on Form field

Context menu on field are nothing but the list of features shown when you do right click on field like filter by field,by selection ,setup etc.
Following code illustrates how you can override the standard context menu and build your own .
Best use of this is in-case of display methods where filter by field and selection are not available.
Override the standard context method available on Form fields.


public void context()
{

   PopupMenu menu ;
   Str filterValue;
   int selectedItem;
   int filter, removeFilter;
   ;

//super(); // Comment standard menu

   menu = new PopupMenu(element.hWnd());
   filter = menu.insertItem("Filter");
   removeFilter= menu.insertItem("Remove Filter");

   selectedItem = menu.draw();
   filterValue = element.design().controlName("Table1_Usn").valueStr();

   switch (selectedItem)
   {
      case filter :
         Table1_ds.filter(fieldnum(table1,Usn),filterValue);
      break;

      case removeFilter :
         Table1_ds.removeFilter();
      break;

   }
}

Happy Daxing!

Aucun commentaire:

Enregistrer un commentaire