How to catch special keystrokes and use them as shortcuts

Rightclick on a form and go down tracking a specific field or other data, is a tedious work if you do it dozens of times per day.

We wanted to catch the key combination ctrl+Z (since it is rarelly used when running axapta), so we could use it to display common data about a form, field or other info. This is a code example we nowdays always install in all new test and development environments (not production, since it would give normal users unwanted access).

The key to this method is adding code in the Task method of the SysSetupFormRun class. Open your AOT, go to the class SysSetupFormRun, expand the Task method and add the code below between the start/end comments. Save the changes. Start up for example SalesTable form, position on a field and press Ctrl+Z, voila – a complete list of that field is listed in the infolog. Maybe you need to restart your client, to get the changes active.

There is a very similar example on kashperuk.blogspot.com but that example seems to be dependt on a external DLL file, this version is not. Originally this code comes from AxaptaPedia but I can not find it now. We do not claim to be the first with this idea, just showing something very useful. This code goes long back. Our changes is minor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
public int task(int _p1)
{
    #task
    FormDataSource formDataSource;
    int ret;
 
    // START 070921 FourOne/JoJ (FO_EnvironmentAddOns4)
    // -- Description: quick-command for checking 
    //                      field and/or form data.
    SysDictField df;    
    FormControl fc;
    formStringControl fsc;
    DictEnum dictEnum = new DictEnum(enumnum(Types));
    DictEnum dictEnums;
    ;
    if (_p1 == 769) //Ctrl + Z
    {
        fc = this.selectedControl();
        formDataSource =  this.objectSet();
 
        if(fc && formDataSource)
        {
            fsc    = fc;
            if(fsc.dataField() && formDataSource.table())
            {
                info(strfmt('Tbl. Fld  -> %2. %1',
                    fieldId2Name(formDataSource.table(),
                                  fsc.dataField() - 65536),
                    tableId2Name(formDataSource.table())));
                df=new SysDictField(formDataSource.table(), 
                                  fsc.dataField() - 65536);
                if(df)
                {
                    info(strfmt('Type      -> %1', 
                        dictEnum.index2Symbol(
                                         df.baseType())));
                    if(df.baseType() == typeOf(Types::Enum))
                    {
                        dictEnums = new dictEnum(
                                              df.enumId());
                        info(strfmt('Enum     -> %1',   
                            dictEnums.name()));
                    }
                    info(strfmt('Ext type -> %1', 
                        extendedTypeId2name(df.typeId())));
                    info(strfmt('Size       -> %1', 
                        int2str(df.stringLen())));
                    info(strfmt('max.rght -> %1', 
                        (df.rights())));
                    info(strfmt('Label      -> %1: %2',
                        (df.labelLabel()),(df.label()) ));
                    info(strfmt('Help       -> %1: %2',
                        (df.helpLabelId()),(df.help()) ));
                }
            }
            if(fsc.dataMethod())
            {
                info(strfmt('METHOD %1.%2',  
                      tableId2Name(formDataSource.table()),
                      fsc.dataMethod()));
            }
        }
    }
    // END 070921 FourOne/JoJ (FO_EnvironmentAddOns4)
 
     if (_p1 == #taskFilter)
    {
        formDataSource = this.objectSet();
        if (formDataSource &&
            formDataSource.queryRun() &&
            formDataSource.queryRun().args() &&
            !formDataSource.queryRun().args().caller())
        {
            formDataSource.queryRun().args().caller(this);
        }
    }
 
    ret = super(_p1);
    return ret;
}

Last 5 posts in Development

Leave a Reply

Your email address will not be published. Required fields are marked *