简体   繁体   中英

e4 KeyBinding and Handler depending on selection

I defined a KeyBinding in my e4 application model. What I want to achieve is that a different handler is used when I press the defined keys - depending on the current selection.

One idea would be to define a common handler which checks the selection and then delegates to the appropriate handler. But I feel this is not optimal and I hope e4 provides some other way of doing this.

One way is to define multiple Binding Contexts each with its own Binding Table. You can then bind the key strokes to different commands in each context.

Use the EContextService to activate a particular binding context:

@Inject
EContextService contextService;


contextService.activateContext("context id");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM