Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In answer to the question of <strong>keyboard chords</strong> specifically, I do not believe there is a ready-made option available to you at this point.</p> <p>However, it should be simple enough to model. I would create a single class, perhaps <code>KeyboardChordProvider</code>. It will need to know about keyboard events at the form level. As stated elsewhere, the <code>Form.KeyPreview</code> property must be <code>true</code>. It may be enough for this provider to subscribe to the <code>Form.KeyPress</code> event. You could do all of this in the provider's constructor if you passed in the form.</p> <p>You would need to register the potential keystrokes with the provider.</p> <p>Internally this instance will track the current state. Whenever a keystroke is observed that represents the first key of the chord, you would update the provider's state and raise an event so that a subscriber could set text: <em>(CTRL+W) was pressed. Waiting for second key of chord...</em></p> <p>If the next keystroke matches a potential secondary option, then you have a match and could raise a <code>ChordPressed</code> event containing the details of the strokes entered. Alternatively, you might just call a particular callback that was given to the provider at the time the chord was registered (to avoid having a switch statement or some other dispatch in the <code>ChordPressed</code> event handler).</p> <p>If, at any time, a keystroke does not match a potential <em>next</em> option, then you would reset the state of the provider.</p> <p>Internal to the provider you might model the possible keystrokes using a tree structure. The current state of the provider is just a particular tree node. At the beginning, the root node would be active. If a child matches a keystroke then it becomes the current node in anticipation of the next stroke. If the child was a leaf node, then an entire chord has matched and you would raise <code>ChordPressed</code> event (passing the chain of strokes that got you to that point) or invoke the callback stored in the leaf. Whenever no keystroke matches a child, reset back to making the root node active.</p> <p>I think this design would achieve what you want.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload