The best way to handle this is as follows:
- Create an action list or action manager or reuse an existing one.
- Add an action that clears the note and moves on to the next. You will need to verify that the active control is indeed a note.
- Give the action the shortcut you want, CTRL + ENTER .
Note that you do not need to apply the action to anything. This simple presence is enough to ensure that the label is processed.
For complex keyboard actions using modifier keys, it is always easier to use the action shortcut and, therefore, maintain the arm length from the lower level keyboard processing code.
Your action handler might look like this:
if ActiveControl is TMemo then begin Memo := TMemo(ActiveControl); Text := Memo.Text; Memo.Clear; SelectNext(Memo, True, True); if ActiveControl is TMemo then begin Memo := TMemo(ActiveControl); Memo.Text := Text; end; end;
In this code, I assume that there are several notes, and the text moves from one note to the next in tab order. But your needs can be very different. In this case, I'm sure it will be obvious what you need to do for your scenario.
source share