06 October 2010

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.

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;
}

1 comment:

  1. Hi, you can just use AxAssist add-on.
    With AxAssist you can setup up to 20 shortcuts in DAX Editor and up to 20 shortcuts for general use.

    Also it has handy toolbar, which duplicate functionality of shortcuts.

    Extended IntelleSense in Editor also is extreamly useful.

    ReplyDelete

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...