~eliasnaur/gio#432: 
key.InputOp set cannot represent minus key

In my calculator application (https://github.com/fjl/gio-demos/tree/master/giocalc), I would like to handle the "minus" key. However, since the minus sign is used in the key.Set syntax, it cannot be matched by Set.Contains, and events for this key are not delivered.

I think the minus key could be supported with this syntax:

op := key.InputOp{
    Set: "(Shift)-(Alt)-[-]",
}
Status
REPORTED
Submitter
~fjl
Assigned to
No-one
Submitted
1 year, 3 months ago
Updated
5 months ago
Labels
No labels applied.

~whereswaldon 1 year, 3 months ago

Thanks for pointing this out! I think these functions need to be taught some kind of escaping syntax to allow that, or maybe we simply need to check whether the final character is "-" and handle that differently. ~eliasnaur, do you have a preference on the approach?

~fjl 1 year, 3 months ago*

Alternative idea: use another data structure for key sets. I'm suggesting this also because there are a few other problems with the current key.Set system being based on a string syntax:

  • it's not intuitive to work with when the declared key set is dynamic
  • the code to match keys must parse the set syntax every time
  • it does not support declaring listeners for modifier-only events (AFAIK)

~fjl 1 year, 3 months ago

I'm happy to work out something better, but it'll take a while.

~eliasnaur 1 year, 3 months ago

Several Gio users have expressed their dislike over the data structure. I'm happy to accept proposals for a replacement, thanks!

~dikey0ficial 8 months ago

+1 to ~fjl's idea, because with existing syntax square braces and commas also couldn't be used.

~dominikh 5 months ago

While we're here, it'd be nice to be able to specify a set matching all keys, without having to specify every possible key. This comes up in modals, as well as in widget.Editor, which mostly uses edit events, causing most key presses to bubble up.

Register here or Log in to comment, or comment via email.