winforms - Strategy to handle shortcuts correctly with a BarManager -


we using devexpress barmanager build our menus know problem described below occurs other menu-handling components well:

we have encountered conceptual problem using barmanager. have base form class our forms derived. base form has barmanager which, matter of fact, handles every shortcut occurs, including shortcuts handled focused control. of course not desired behaviour. consider example: if text box focussed, hitting ctrl + c not cause text box copy text-value clipboard. instead, barmanager fire baritemclick-event.

now have evaluated several strategies solve problem in generic way. have requirement our framework handles problem entirely, , individual programmers or applications not have care it. solution suggested in following example not applicable, because depends on application-specific logic: example.

we found out there 2 ways solve problem generically:

  1. the barmanager handles shortcut in baritemclick event handler. if control focussed, control told take care of shortcut if possible. if control not take care of shortcut (e.g. because shortcut ctrl + s), barmanager passes event application (e.g. save current document on ctrl + s).
  2. the barmanager has shortcutitemclick event fired whenever shortcut occurs. in respective event handler, focussed control asked whether can handle shortcut. if yes (e.g. ctrl + c), barmanager cancel handling shortcut , control react on shortcut if there no barmanager @ (e.g. copy controls content clipboard). if no (e.g. ctrl + s), barmanager handle shortcut, means fires baritemclick event, lead application taking care of (e.g. save current document).

now each solution have several ideas how implementation like, not working satisfying way:

for solution 1:

a) call baseedit.sendkey() on focussed control. self-contained solution because there no logic implemented. problem is: calling baseedit.sendkey() , passing key of shortcut has no effect. example sendkey(new keyeventargs(keys.delete)) not delete selection of focussed text box. question is: why method call have no effect?

b) define interface ishortcuthandler has 1 method handleshortcut(). used controls implement interface in following way:

public void handleshortcut(keyeventargs args) {   base.onkeydown(args); } 

this solution has problem calling onkeydown has no effect, in a). question is: why this?

for solution 2:

a) call method on control determines whether control able handle shortcut. question is: there such method or helper class or library or can take decision?

are there other strategies or solutions can think of?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -