开发者

How to prevent shortcuts from firing when form is not active

I open forms inside tabs of a page control. These forms may contain actions开发者_StackOverflow with shortcuts. And I want these shortcuts to be fired only when the tab that contain this form is active.

I tried to override form's IsShortCut but it's not called. Form's OnShortCut is not called either.

I would like to avoid putting code on each action to check this.

I'm using Delphi 2010.


Set the State for the action lists on your hidden tabs to asSuspended. Only the action list on your visible tab should have a state of asNormal. That will prevent the shortcut keys from working. It also prevents those actions from updating, which may or may not be a good thing for your application.


Try setting the form's Enabled to false whan you switch away, and True when you switch onto it's tab. That should disable all the content on the form, including shortcuts.


Put all the shortcuts into actions and those actions into one action list per form. Then you can disable the action lists of the forms that are currently not active. (I don't recall the exact TActionList property to set or method to call or activating/deactivating it, but it is there.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜