I'm not sure about correct solution but I think Key.fromMask should be a bit clever.
P.S. Thanks to Kaushik this issue can be reproduced right here: http://www.fanzy.net/
brianMon 23 May 2011
Promoted to ticket #1543 and assigned to brian
Yeah, I agree that method needs to more sophisticated to handle modifier combos
Yuri StrotTue 24 May 2011
Looks like fwt::Key.fromMask mostly used for key codes. The only exception is fwt::Key.modifiers. May be it makes sense to leave fromMask for key codes and handle modifiers separately:
diff --git a/src/fwt/fan/Key.fan b/src/fwt/fan/Key.fan
--- a/src/fwt/fan/Key.fan
+++ b/src/fwt/fan/Key.fan
@@ -265,12 +265,20 @@
**
** Decompose the key into its primary key (without modifiers).
**
- Key primary() { fromMask(mask.and(modifierMask.not)) }
+ Key primary() { fromMask(mask.and(modifierUnmask)) }
**
** Return a Key instance with only the modifiers.
**
- Key modifiers() { fromMask(mask.and(modifierMask)) }
+ Key modifiers()
+ {
+ key := none
+ if (isAlt) key += alt
+ if (isShift) key += shift
+ if (isCtrl) key += ctrl
+ if (isCommand) key += command
+ return key
+ }
**
** Is this instance is a modifier which may be combined
@@ -316,6 +324,8 @@
@Operator Key plus(Key x)
{
if (!isModifier && !x.isModifier) throw ArgErr("Neither is modifier: $this + $x")
+ if (mask == 0) return x
+ if (x.mask == 0) return this
return makeNew(mask.or(x.mask), null)
}
Yuri Strot Mon 23 May 2011
Following example:
causes following exception:
I'm not sure about correct solution but I think
Key.fromMask
should be a bit clever.P.S. Thanks to Kaushik this issue can be reproduced right here: http://www.fanzy.net/
brian Mon 23 May 2011
Promoted to ticket #1543 and assigned to brian
Yeah, I agree that method needs to more sophisticated to handle modifier combos
Yuri Strot Tue 24 May 2011
Looks like fwt::Key.fromMask mostly used for key codes. The only exception is fwt::Key.modifiers. May be it makes sense to leave
fromMask
for key codes and handle modifiers separately:brian Tue 24 May 2011
Ticket resolved in 1.0.59
Great patch, thanks Yuri
changeset