问题
Does anybody knows how to store keystroke as a string in X++?
And also if I want to covert them to ASCII and vise-versa.
And the below job does not shows the expected behaviour.
public void textChange()
{
int i, j;
int L = 12;
int h = 4;
int t = 54;
str tmpStr;
;
i = strLen(strKeep(seField.text(), '\n'));
info(seField.text() + ' Lines: ' + int2str(i));
super();
if (i >= H)
{
error(strFmt("max lines = %1", h));
}
}
Actually i am trying to implement something like-
in a textChange method of stringEdit when i enter "A"(or any value) it should display "A line 0"(in info log) then i enter B it should display "AB line 0" (in info). Once i press enter and the enter "Q" display shoud be something like "AB Line 0"(1st line) "Q Line 1"(2nd line) and so on. I face problem with "\n"(Enter) So I need to achieve this through ASCII value. Thanks.
回答1:
I don't see how task()
is going to help you.
It seems that when the StringEdit
control contains carriage returns, StringEdit.text()
is always giving a wrong result when you're checking it in the textChange()
method. Probably an AX bug. You can use the modified()
method to get the correct result at least afterwards.
Exportfile for AOT version 1.0 or later
Formatversion: 1
***Element: FRM
; Microsoft Dynamics AX Forms unloaded
; --------------------------------------------------------------------------------
FRMVERSION 5
FORM #TestForm1
PROPERTIES
Name #TestForm1
ENDPROPERTIES
METHODS
Version: 3
SOURCE #updateOutput
#void updateOutput()
#{
# container c = str2con(Input.text(), '\n');
# int i;
# str s;
# ;
#
# for (i = 1; i <= conlen(c); i++)
# s += strfmt("Line %1: %2\n", i, conpeek(c, i));
#
# Output.text(s);
#}
ENDSOURCE
SOURCE #classDeclaration
#public class FormRun extends ObjectRun
#{
#
#}
ENDSOURCE
ENDMETHODS
OBJECTBANK
PROPERTIES
ENDPROPERTIES
ENDOBJECTBANK
JOINS
ENDJOINS
DESIGN
PROPERTIES
ENDPROPERTIES
CONTAINER
CONTROL STRINGEDIT
PROPERTIES
Name #Input
AutoDeclaration #Yes
Width #Column width
Height #Column height
MultiLine #Yes
ENDPROPERTIES
METHODS
Version: 3
SOURCE #modified
#public boolean modified()
#{
# boolean ret = super();
# ;
#
# element.updateOutput();
#
# return ret;
#}
ENDSOURCE
SOURCE #textChange
#public void textChange()
#{
# super();
#
# element.updateOutput();
#}
ENDSOURCE
ENDMETHODS
ENDCONTROL
CONTROL STRINGEDIT
PROPERTIES
Name #Output
AutoDeclaration #Yes
AllowEdit #No
Width #Column width
MultiLine #Yes
ENDPROPERTIES
ENDCONTROL
ENDCONTAINER
ENDDESIGN
ENDFORM
***Element: END
Update. You can probably trigger the modified()
method from textChange()
- that would be a hack, I didn't try it.
回答2:
The only way to store keystrokes in an AX form is use the task()
method on the form.
But do not do it for the purpose you commented on!
Rather use a enum value or a combobox feeded with the relevant values to get the wanted behavior.
UPDATE:
You may find some useful information on this subject here: http://www.axaptapedia.com/FormComboBoxControl
and here: http://blogs.msdn.com/b/palle_agermark/archive/2005/06/30/434146.aspx
回答3:
Try the SearchMode
attribute of string control. To be useful the string value has to be mapped to an indexed table field.
来源:https://stackoverflow.com/questions/5401570/store-keystrokes-in-x