-1

I would like to be able to handle the input that is sent to a form in AX. Is there any way of doing this?

And this has to be for all keyboard input for a form.

For example, there is the SysSetupFormRun.task() method where you can detect a limited number of tasks, but, from what I have seen and tried, it does handle all keyboard input.

user3660338
  • 296
  • 5
  • 23
  • What code have you tried so far? – Chris May 21 '14 at 10:48
  • I have tried with the task method and a few other methods in that class to see if they gave any results, but none of them worked. – user3660338 May 21 '14 at 11:18
  • Just to clarify, you want to intercept user input from the keyboard to the form, not from the form to the database? Since new/modified records are local changes only until the record is either saved manually or the record selection is switched, I'm having trouble thinking of why you would need this. Could you give an example? Is this needed on a specific form, or to all forms? – kingofzeal May 21 '14 at 11:56
  • Yes, the user input from the keyboard to the form. – user3660338 May 21 '14 at 12:16
  • Do you have an example of what you would do with this information? It almost sounds like you would be better off with a 3rd party keylogger-ish program. – kingofzeal May 21 '14 at 12:38
  • When the form is being used, the user scans an item. I would like it so that it does not matter where the focus is in the form when the user scans the item. When it is then scanned, I need to display information based on the item that is scanned. – user3660338 May 21 '14 at 12:42
  • Ah, like you have a barcode scanner and it automatically dumps its input into the currently active field and you want to intercept that and handle it differently? – tgolisch May 21 '14 at 14:16
  • @tlogisch: Yes, exactly. – user3660338 May 21 '14 at 14:24

1 Answers1

0

From my understanding you have a couple requirements:

  1. The form should redirect any input from the keyboard to a specific field, regardless of which field currently has focus.
  2. Presented information based on the input field in point #1 may or may not be available for a user to interact with (eg, copy the value of a field or add additional data to the information provided).
  3. This redirection should only occur on a definite number of forms, not on every form in the system.

Just a real quick note with point #3: It will be difficult to do what you are looking for without affecting every form in the system. Keyboard input would likely be managed at the FormRun level (the base class for all forms) or higher, so tapping into that in specific form instance would prove difficult and require considerable care that it doesn't impact every other form in the system. Because of this, you should focus on changing the specific form. Also, from my experience, several functions globally available on forms are not available for us to manage/override/edit (like certain steps in the Export to Excel function as an example), so it's unlikely you would be able to override keyboard interaction in any case.

The biggest problem stems from determining what input should be redirected and what input should not (eg Ctrl + C, Ctrl + X, etc). If requirement #2 does not need the ability for a user to do anything with the data except read it, then I would propose overriding the lostFocus method of the input field with code that would automatically give focus back to the field. It would look something like this:

public void lostFocus()
{
    super();

    this.setFocus()
}

Again, the main problem with this being that the user will not be able to select anything else on the form. If the information is only to be read (like a summary screen, for example), this should not be an issue.

If the user does need to interact with the information presented (eg, to copy a description from a field), you could probably apply similar logic to those fields so that if any input would be entered, it would change focus to the input field. This could be triggered with the textChange method, but you would likely miss some of the text during the transition:

public void textChange()
{
    super();

    //Note: the control fieldName will need to have AutoDeclaration set to Yes
    fieldName.setFocus();
}

If this doesn't work properly, you may need to search for an ActiveX control, which should allow you to specify that all input goes to the input field, and update the content as needed. It would likely need to be all-encompassing (the control would contain controls for input and display), so it may not have the same look and feel as the rest of AX, but should be able to do what you need.

kingofzeal
  • 1,359
  • 3
  • 12
  • 24