Skip to main content

Catching a key stroke in AX 2012

Courtesy: http://www.doens.be/2010/03/catching-a-key-press/

When you want to catch a key-stroke on a form, you can override the method task()
The default method will look like this:
public int task(int _taskId)
{
    int ret;
    ret = super(_taskId);
    // write you're code here
    return ret;
}
Now you just need to check the _taskId, to know witch key you have stroke. You can compare this withe the values from the Task-macro.
// Task-ID values, to be used with formControl's
// return value from the method task()
//--------------------------------------------------------
 
#define.taskF1(257)
#define.taskCtrlQ(264)
#define.taskEnter(288)
#define.taskShiftEnter(307)
#define.taskNew(260)
#define.taskSave(272)
 
#define.taskShortCutMenuKey(519)
#define.taskAlt(520)
 
#define.taskCut(770)
#define.taskCopy(771)
#define.taskPaste(772)
 
#define.taskDeleteKey(773)
#define.taskSelectAll(778)
 
#define.taskUndo(769)
#define.taskRedo(791)
 
#define.taskArrowUp(1281)
#define.taskArrowDown(1282)
#define.taskArrowLeft(1283)
#define.taskArrowRight(1284)
 
// PgUp and PgDn are the numerical keyboard page up and page down commands.
#define.taskPgUp(1285)
#define.taskPgDn(1286)
 
#define.taskEsc(1313)
 
#define.taskNextRecord(2817)
#define.taskPrevRecord(2818)
 
#define.taskDeleteRecord(2832)
 
#define.taskPageDown(2819)
#define.taskPageUp(2820)
 
#define.taskTab(2827)
#define.taskNext(2827)
#define.taskPrev(2828)
 
#define.taskShortCutMenuFilter(2844)
#define.taskShortCutMenuFind(799)
#define.taskFilter(2837)
 
// max task id
#define.taskLast(8191)

Comments

Popular posts from this blog

Get Position and Department of an employee | AX 2012

A simple job to get position/designation and department of an employee using employee id: static void WorkerPositionDepartment(Args _args) {     HcmWorker                       hcmWorker;     HcmPositionWorkerAssignment     hcmPositionWorkerAssignment;     OMOperatingUnit                 oMOperatingUnit;     HcmPositionDetail               hcmPositionDetail;     HcmJob                          hcmJob;     HcmPosition             ...

Run SSRS report using x++ code | AX 2012

This post describes how to run an SSRS report through x++ code and passing report parameters as well. Its a simple code and comments are added for further ease in code understanding! public static void runSSRSReport() {     SrsReportRunController controller;             controller = new SrsReportRunController();     controller.parmLoadFromSysLastValue(false);      // write report name and its design in quotes that you want to run     controller.parmReportName("ReportName.DesignName");      // set additional, optional properties like setting landscape to true     controller.parmReportContract().parmPrintSettings().landscape(true);          // set print destination screen/printer/file etc.     controller.parmReportContract().parmPrintSettings().printMediumType (SRSPrintMediumType::S...

How to pass value from form to class, AX 2012

Courtesy : DUG Dynamics User Group It's very simple to pass value from a form to a class by defining a method on form and using args.caller() in the class. 1. Take a String control in the form design like  string Customer Name. 2. Go to String control properties and set "Auto declaration" property to "Yes". 3. Go to form methods -> new method -> write return type method like;           public str customerName()      {            return CustomerName.Text();      } 4. Go to main() method of the class and type following:     public static void main(Args args)     {            str custName;            ;                if(formHasMethod(a...