|
07.04.2011, 12:11 | #1 |
Участник
|
palleagermark: Create your own shortcuts in AX forms
Источник: http://palleagermark.blogspot.com/20...-ax-forms.html
============== In AX it is virtually impossible to control the shortcuts of buttons. Even though button properties like KeyTip indicate that you should be able to have some control, nothing really works. Here is a tip on how you can catch special keyboard combinations yourself, and thus create your own shortcuts. First you need to call a method from USER32.DLL to figure out if a certain key is pressed. You could for example implement this on the WinAPI class: X++: static boolean getKeyPressed(int _keyCode) { DLL winApiDLL = new DLL('USER32'); DLLFunction getKeyState = new DLLFunction(winApiDLL, 'GetAsyncKeyState'); int result; ; getKeyState.returns(ExtTypes::WORD); getKeyState.arg(ExtTypes::DWORD); result = getKeyState.call(_keyCode); if ((result & 0x8000) == 0x8000) return true; else return false; } On your form you need to implement a method that is executed again and again while the form is idle. The method needs to check if your special key combination is pressed, do the action associated with the key and set the method up for next iteration. It could look like this: X++: void myKeyboardCheck() { #define.ALT(0x12) #define.O(0x4F) #define.timeOut(10) ; // Check if this form is the foreground window of Windows if (winApi::getForegroundWindow() == this.hWnd()) { // Check if ALT + O is pressed if (WinApi::getKeyPressed(#ALT) && WinApi::getKeyPressed(#O)) { // Check if the button is enabled if (MyVerySpecialButton.enabled()) { MyVerySpecialButton.clicked(); } } } // Reset timer this.setTimeOut('myKeyboardCheck', #timeOut, true); } X++: MyVerySpecialButton.text(MyVerySpecialButton.labelText() +' (o)');
this.myKeyboardCheck(); If you need to catch keyboard combinations at a global level, you should hook into the Info.OnEventGoingIdle() method. Global reserved keys are defined under \Application Documentation\Global\Shortcutkeys. I want to give a big thank you to Amitha Madathil Pottayil from Microsoft support for pointing me in the right direction. I can only wonder why Microsoft haven't gotten this stuff correctly wired up in the first place. Источник: http://palleagermark.blogspot.com/20...-ax-forms.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. Последний раз редактировалось Poleax; 07.04.2011 в 12:56. |
|
|
|