Catching a key-press

  • March 10, 2010
  • 1 Comment

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)