Changed the meaning of the Modifiers keys to be positional, added Super, and pinned down Meta vs. Alt. All but the Meta/Alt one were done after discussion in #go-nuts about how to handle differences in user expectation properly. This is the portable interface only; each platform implementation comes next.
This commit is contained in:
parent
da2bd70192
commit
13397f91ee
6
area.go
6
area.go
|
@ -277,10 +277,10 @@ func (e KeyEvent) EffectiveKey() byte {
|
|||
// As such, what KeyEvents get sent if the user does something unusual with both of a certain modifier key at once is (presently; TODO) undefined.
|
||||
type Modifiers uintptr
|
||||
const (
|
||||
Ctrl Modifiers = 1 << iota // the canonical Ctrl keys ([TODO] on Mac OS X, Control on others)
|
||||
Alt // the canonical Alt keys ([TODO] on Mac OS X, Meta on Unix systems, Alt on others)
|
||||
Ctrl Modifiers = 1 << iota // the keys labelled Ctrl or Control on all platforms
|
||||
Alt // the keys labelled Alt or Option or Meta on all platforms
|
||||
Shift // the Shift keys
|
||||
// TODO add Super
|
||||
Super // the Super keys on platforms that have one, or the Windows keys on Windows, or the Command keys on Mac OS X
|
||||
)
|
||||
|
||||
func checkAreaSize(width int, height int, which string) {
|
||||
|
|
|
@ -64,9 +64,9 @@ func (a *keyboardArea) Key(e KeyEvent) (handled bool, repaint bool) {
|
|||
if (m & Shift) != 0 {
|
||||
markkey(a.kbd, modpoints[Shift], m &^ Shift)
|
||||
}
|
||||
// if (m & Super) != 0 {
|
||||
// markkey(a.kbd, modpoints[Super], m &^ Super)
|
||||
// }
|
||||
if (m & Super) != 0 {
|
||||
markkey(a.kbd, modpoints[Super], m &^ Super)
|
||||
}
|
||||
default:
|
||||
return false, false
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ func kbTest() {
|
|||
var (
|
||||
keywid = 36
|
||||
keyht = 24
|
||||
// 8 rects per key, 4x2 grid
|
||||
// 16 rects per key, 4x4 grid
|
||||
rectsperrow = 4
|
||||
rectspercol = 2
|
||||
rectspercol = 4
|
||||
keyrectwid = keywid / rectsperrow
|
||||
keyrectht = keyht / rectspercol
|
||||
_keyrect = image.Rect(0, 0, keyrectwid, keyrectht)
|
||||
|
@ -103,6 +103,11 @@ func modcolor(m Modifiers) *image.Uniform {
|
|||
r := (m & 1) * 255; m >>= 1
|
||||
g := (m & 1) * 255; m >>= 1
|
||||
b := (m & 1) * 255; m >>= 1
|
||||
if (m & 1) == 1 { // Super
|
||||
r /= 2
|
||||
g /= 2
|
||||
b /= 2
|
||||
}
|
||||
return image.NewUniform(color.NRGBA{byte(r), byte(g), byte(b), 255})
|
||||
}
|
||||
|
||||
|
@ -206,7 +211,7 @@ var modpoints = map[Modifiers]image.Point{
|
|||
Ctrl: image.Pt(4, 199),
|
||||
Alt: image.Pt(113, 199),
|
||||
Shift: image.Pt(4, 159),
|
||||
// Super: image.Pt(61, 199),
|
||||
Super: image.Pt(61, 199),
|
||||
}
|
||||
|
||||
// source: http://openclipart.org/image/800px/svg_to_png/154537/1312973798.png (medium image) via http://openclipart.org/detail/154537/us-english-keyboard-layout-v0.1-by-nitiraseem
|
||||
|
|
Loading…
Reference in New Issue