More go fmt. That completes the main package go fmt. Won't bother with test or tools.
This commit is contained in:
parent
a210775287
commit
5fa1bd22e2
106
area.go
106
area.go
|
@ -4,10 +4,10 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
|
||||||
"image"
|
"image"
|
||||||
"unsafe"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sync"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Area represents a blank canvas upon which programs may draw anything and receive arbitrary events from the user.
|
// Area represents a blank canvas upon which programs may draw anything and receive arbitrary events from the user.
|
||||||
|
@ -16,10 +16,10 @@ import (
|
||||||
// The coordinate system of an Area always has an origin of (0,0) which maps to the top-left corner; all image.Points and image.Rectangles sent across Area's channels conform to this.
|
// The coordinate system of an Area always has an origin of (0,0) which maps to the top-left corner; all image.Points and image.Rectangles sent across Area's channels conform to this.
|
||||||
// The size of an Area must be at least 1x1 (that is, neither its width nor its height may be zero or negative).
|
// The size of an Area must be at least 1x1 (that is, neither its width nor its height may be zero or negative).
|
||||||
// For control layout purposes, an Area prefers to be at the size you set it to (so if an Area is not stretchy in its layout, it will ask to have that size).
|
// For control layout purposes, an Area prefers to be at the size you set it to (so if an Area is not stretchy in its layout, it will ask to have that size).
|
||||||
//
|
//
|
||||||
// To handle events to the Area, an Area must be paired with an AreaHandler.
|
// To handle events to the Area, an Area must be paired with an AreaHandler.
|
||||||
// See AreaHandler for details.
|
// See AreaHandler for details.
|
||||||
//
|
//
|
||||||
// Do not use an Area if you intend to read text.
|
// Do not use an Area if you intend to read text.
|
||||||
// Area reads keys based on their position on a standard
|
// Area reads keys based on their position on a standard
|
||||||
// 101-key keyboard, and does no character processing.
|
// 101-key keyboard, and does no character processing.
|
||||||
|
@ -28,12 +28,12 @@ import (
|
||||||
// to lead to trouble.
|
// to lead to trouble.
|
||||||
// [FOR FUTURE PLANNING Use TextArea instead, providing a TextAreaHandler.]
|
// [FOR FUTURE PLANNING Use TextArea instead, providing a TextAreaHandler.]
|
||||||
type Area struct {
|
type Area struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
created bool
|
created bool
|
||||||
sysData *sysData
|
sysData *sysData
|
||||||
handler AreaHandler
|
handler AreaHandler
|
||||||
initwidth int
|
initwidth int
|
||||||
initheight int
|
initheight int
|
||||||
}
|
}
|
||||||
|
|
||||||
// AreaHandler represents the events that an Area should respond to.
|
// AreaHandler represents the events that an Area should respond to.
|
||||||
|
@ -78,40 +78,40 @@ type AreaHandler interface {
|
||||||
// The association between button numbers and physical buttons are system-defined.
|
// The association between button numbers and physical buttons are system-defined.
|
||||||
// For example, on Windows, buttons 4 and 5 are mapped to what are internally referred to as "XBUTTON1" and "XBUTTON2", which often correspond to the dedicated back/forward navigation buttons on the sides of many mice.
|
// For example, on Windows, buttons 4 and 5 are mapped to what are internally referred to as "XBUTTON1" and "XBUTTON2", which often correspond to the dedicated back/forward navigation buttons on the sides of many mice.
|
||||||
// The examples here are NOT a guarantee as to how many buttons maximum will be available on a given system.
|
// The examples here are NOT a guarantee as to how many buttons maximum will be available on a given system.
|
||||||
//
|
//
|
||||||
// If the user clicked on the Area to switch to the Window it is contained in from another window in the OS, the Area will receive a MouseEvent for that click.
|
// If the user clicked on the Area to switch to the Window it is contained in from another window in the OS, the Area will receive a MouseEvent for that click.
|
||||||
type MouseEvent struct {
|
type MouseEvent struct {
|
||||||
// Pos is the position of the mouse in the Area at the time of the event.
|
// Pos is the position of the mouse in the Area at the time of the event.
|
||||||
Pos image.Point
|
Pos image.Point
|
||||||
|
|
||||||
// If the event was generated by a mouse button being pressed, Down contains the ID of that button.
|
// If the event was generated by a mouse button being pressed, Down contains the ID of that button.
|
||||||
// Otherwise, Down contains 0.
|
// Otherwise, Down contains 0.
|
||||||
// If Down contains nonzero, the Area will also receive keyboard focus.
|
// If Down contains nonzero, the Area will also receive keyboard focus.
|
||||||
Down uint
|
Down uint
|
||||||
|
|
||||||
// If the event was generated by a mouse button being released, Up contains the ID of that button.
|
// If the event was generated by a mouse button being released, Up contains the ID of that button.
|
||||||
// Otherwise, Up contains 0.
|
// Otherwise, Up contains 0.
|
||||||
// If both Down and Up are 0, the event represents mouse movement (with optional held buttons for dragging; see below).
|
// If both Down and Up are 0, the event represents mouse movement (with optional held buttons for dragging; see below).
|
||||||
// Down and Up shall not both be nonzero.
|
// Down and Up shall not both be nonzero.
|
||||||
Up uint
|
Up uint
|
||||||
|
|
||||||
// If Down is nonzero, Count indicates the number of clicks: 1 for single-click, 2 for double-click, 3 for triple-click, and so on.
|
// If Down is nonzero, Count indicates the number of clicks: 1 for single-click, 2 for double-click, 3 for triple-click, and so on.
|
||||||
// The order of events will be Down:Count=1 -> Up -> Down:Count=2 -> Up -> Down:Count=3 -> Up -> ...
|
// The order of events will be Down:Count=1 -> Up -> Down:Count=2 -> Up -> Down:Count=3 -> Up -> ...
|
||||||
Count uint
|
Count uint
|
||||||
|
|
||||||
// Modifiers is a bit mask indicating the modifier keys being held during the event.
|
// Modifiers is a bit mask indicating the modifier keys being held during the event.
|
||||||
Modifiers Modifiers
|
Modifiers Modifiers
|
||||||
|
|
||||||
// Held is a slice of button IDs that indicate which mouse buttons are being held during the event.
|
// Held is a slice of button IDs that indicate which mouse buttons are being held during the event.
|
||||||
// Held will not include Down and Up.
|
// Held will not include Down and Up.
|
||||||
// Held will be sorted.
|
// Held will be sorted.
|
||||||
// Only buttons 1, 2, and 3 are guaranteed to be detected by Held properly; whether or not any others are is implementation-defined.
|
// Only buttons 1, 2, and 3 are guaranteed to be detected by Held properly; whether or not any others are is implementation-defined.
|
||||||
//
|
//
|
||||||
// If Held is non-empty but Up and Down are both zero, the mouse is being dragged, with all the buttons in Held being held.
|
// If Held is non-empty but Up and Down are both zero, the mouse is being dragged, with all the buttons in Held being held.
|
||||||
// Whether or not a drag into an Area generates MouseEvents is implementation-defined.
|
// Whether or not a drag into an Area generates MouseEvents is implementation-defined.
|
||||||
// Whether or not a drag over an Area when the program is inactive generates MouseEvents is also implementation-defined.
|
// Whether or not a drag over an Area when the program is inactive generates MouseEvents is also implementation-defined.
|
||||||
// Moving the mouse over an Area when the program is inactive and no buttons are held will, however, generate MouseEvents.
|
// Moving the mouse over an Area when the program is inactive and no buttons are held will, however, generate MouseEvents.
|
||||||
Held []uint
|
Held []uint
|
||||||
}
|
}
|
||||||
|
|
||||||
// HeldBits returns Held as a bit mask.
|
// HeldBits returns Held as a bit mask.
|
||||||
|
@ -124,12 +124,12 @@ func (e MouseEvent) HeldBits() (h uintptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// A KeyEvent represents a keypress in an Area.
|
// A KeyEvent represents a keypress in an Area.
|
||||||
//
|
//
|
||||||
// Key presses are based on their positions on a standard
|
// Key presses are based on their positions on a standard
|
||||||
// 101-key keyboard found on most computers. The
|
// 101-key keyboard found on most computers. The
|
||||||
// names chosen for keys here are based on their names
|
// names chosen for keys here are based on their names
|
||||||
// on US English QWERTY keyboards; see Key for details.
|
// on US English QWERTY keyboards; see Key for details.
|
||||||
//
|
//
|
||||||
// If a key is pressed that is not supported by Key, ExtKey,
|
// If a key is pressed that is not supported by Key, ExtKey,
|
||||||
// or Modifiers, no KeyEvent will be produced.
|
// or Modifiers, no KeyEvent will be produced.
|
||||||
type KeyEvent struct {
|
type KeyEvent struct {
|
||||||
|
@ -156,24 +156,24 @@ type KeyEvent struct {
|
||||||
// - '\n' if the typewriter Enter key was pressed
|
// - '\n' if the typewriter Enter key was pressed
|
||||||
// - '\b' if the typewriter Backspace key was pressed
|
// - '\b' if the typewriter Backspace key was pressed
|
||||||
// If this value is zero, see ExtKey.
|
// If this value is zero, see ExtKey.
|
||||||
Key byte
|
Key byte
|
||||||
|
|
||||||
// If Key is zero, ExtKey contains a predeclared identifier
|
// If Key is zero, ExtKey contains a predeclared identifier
|
||||||
// naming an extended key. See ExtKey for details.
|
// naming an extended key. See ExtKey for details.
|
||||||
// If both Key and ExtKey are zero, a Modifier by itself
|
// If both Key and ExtKey are zero, a Modifier by itself
|
||||||
// was pressed. Key and ExtKey will not both be nonzero.
|
// was pressed. Key and ExtKey will not both be nonzero.
|
||||||
ExtKey ExtKey
|
ExtKey ExtKey
|
||||||
|
|
||||||
// If both Key and ExtKey are zero, Modifier will contain exactly one of its bits set, indicating which Modifier was pressed or released.
|
// If both Key and ExtKey are zero, Modifier will contain exactly one of its bits set, indicating which Modifier was pressed or released.
|
||||||
// As with Modifiers itself, there is no way to differentiate between left and right modifier keys.
|
// As with Modifiers itself, there is no way to differentiate between left and right modifier keys.
|
||||||
// As such, the result of pressing and/or releasing both left and right of the same Modifier is system-defined.
|
// As such, the result of pressing and/or releasing both left and right of the same Modifier is system-defined.
|
||||||
// Furthermore, the result of holding down a Key or ExtKey, then pressing a Modifier, and then releasing the original key is system-defined.
|
// Furthermore, the result of holding down a Key or ExtKey, then pressing a Modifier, and then releasing the original key is system-defined.
|
||||||
// Under no condition shall Key, ExtKey, AND Modifier all be zero.
|
// Under no condition shall Key, ExtKey, AND Modifier all be zero.
|
||||||
Modifier Modifiers
|
Modifier Modifiers
|
||||||
|
|
||||||
// Modifiers contains all the modifier keys currently being held at the time of the KeyEvent.
|
// Modifiers contains all the modifier keys currently being held at the time of the KeyEvent.
|
||||||
// If Modifier is nonzero, Modifiers will not contain Modifier itself.
|
// If Modifier is nonzero, Modifiers will not contain Modifier itself.
|
||||||
Modifiers Modifiers
|
Modifiers Modifiers
|
||||||
|
|
||||||
// If Up is true, the key was released; if not, the key was pressed.
|
// If Up is true, the key was released; if not, the key was pressed.
|
||||||
// There is no guarantee that all pressed keys shall have
|
// There is no guarantee that all pressed keys shall have
|
||||||
|
@ -181,14 +181,15 @@ type KeyEvent struct {
|
||||||
// programs while holding the key down, then releases the key).
|
// programs while holding the key down, then releases the key).
|
||||||
// Keys that have been held down are reported as multiple
|
// Keys that have been held down are reported as multiple
|
||||||
// key press events.
|
// key press events.
|
||||||
Up bool
|
Up bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtKey represents keys that are not in the typewriter section of the keyboard.
|
// ExtKey represents keys that are not in the typewriter section of the keyboard.
|
||||||
type ExtKey uintptr
|
type ExtKey uintptr
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Escape ExtKey = iota + 1
|
Escape ExtKey = iota + 1
|
||||||
Insert // equivalent to "Help" on Apple keyboards
|
Insert // equivalent to "Help" on Apple keyboards
|
||||||
Delete
|
Delete
|
||||||
Home
|
Home
|
||||||
End
|
End
|
||||||
|
@ -198,7 +199,7 @@ const (
|
||||||
Down
|
Down
|
||||||
Left
|
Left
|
||||||
Right
|
Right
|
||||||
F1 // F1..F12 are guaranteed to be consecutive
|
F1 // F1..F12 are guaranteed to be consecutive
|
||||||
F2
|
F2
|
||||||
F3
|
F3
|
||||||
F4
|
F4
|
||||||
|
@ -210,8 +211,8 @@ const (
|
||||||
F10
|
F10
|
||||||
F11
|
F11
|
||||||
F12
|
F12
|
||||||
N0 // numpad keys; independent of Num Lock state
|
N0 // numpad keys; independent of Num Lock state
|
||||||
N1 // N0..N9 are guaranteed to be consecutive
|
N1 // N0..N9 are guaranteed to be consecutive
|
||||||
N2
|
N2
|
||||||
N3
|
N3
|
||||||
N4
|
N4
|
||||||
|
@ -226,7 +227,7 @@ const (
|
||||||
NSubtract
|
NSubtract
|
||||||
NMultiply
|
NMultiply
|
||||||
NDivide
|
NDivide
|
||||||
_nextkeys // for sanity check
|
_nextkeys // for sanity check
|
||||||
)
|
)
|
||||||
|
|
||||||
// EffectiveKey returns e.Key if it is set.
|
// EffectiveKey returns e.Key if it is set.
|
||||||
|
@ -241,7 +242,7 @@ func (e KeyEvent) EffectiveKey() byte {
|
||||||
k := e.ExtKey
|
k := e.ExtKey
|
||||||
switch {
|
switch {
|
||||||
case k >= N0 && k <= N9:
|
case k >= N0 && k <= N9:
|
||||||
return byte(k - N0) + '0'
|
return byte(k-N0) + '0'
|
||||||
case k == NDot:
|
case k == NDot:
|
||||||
return '.'
|
return '.'
|
||||||
case k == NEnter:
|
case k == NEnter:
|
||||||
|
@ -262,11 +263,12 @@ func (e KeyEvent) EffectiveKey() byte {
|
||||||
// There is no way to differentiate between left and right modifier keys.
|
// There is no way to differentiate between left and right modifier keys.
|
||||||
// As such, what KeyEvents get sent if the user does something unusual with both of a certain modifier key at once is undefined.
|
// As such, what KeyEvents get sent if the user does something unusual with both of a certain modifier key at once is undefined.
|
||||||
type Modifiers uintptr
|
type Modifiers uintptr
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Ctrl Modifiers = 1 << iota // the keys labelled Ctrl or Control on all platforms
|
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
|
Alt // the keys labelled Alt or Option or Meta on all platforms
|
||||||
Shift // the Shift keys
|
Shift // the Shift keys
|
||||||
Super // the Super keys on platforms that have one, or the Windows keys on Windows, or the Command keys on Mac OS X
|
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) {
|
func checkAreaSize(width int, height int, which string) {
|
||||||
|
@ -283,10 +285,10 @@ func NewArea(width int, height int, handler AreaHandler) *Area {
|
||||||
panic("handler passed to NewArea() must not be nil")
|
panic("handler passed to NewArea() must not be nil")
|
||||||
}
|
}
|
||||||
return &Area{
|
return &Area{
|
||||||
sysData: mksysdata(c_area),
|
sysData: mksysdata(c_area),
|
||||||
handler: handler,
|
handler: handler,
|
||||||
initwidth: width,
|
initwidth: width,
|
||||||
initheight: height,
|
initheight: height,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,11 +338,11 @@ func (a *Area) make(window *sysData) error {
|
||||||
|
|
||||||
func (a *Area) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
|
func (a *Area) setRect(x int, y int, width int, height int, rr *[]resizerequest) {
|
||||||
*rr = append(*rr, resizerequest{
|
*rr = append(*rr, resizerequest{
|
||||||
sysData: a.sysData,
|
sysData: a.sysData,
|
||||||
x: x,
|
x: x,
|
||||||
y: y,
|
y: y,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,16 +375,16 @@ func toARGB(i *image.RGBA, memory uintptr, memstride int) {
|
||||||
nextp := p + i.Stride
|
nextp := p + i.Stride
|
||||||
nextq := q + memstride
|
nextq := q + memstride
|
||||||
for x := i.Rect.Min.X; x < i.Rect.Max.X; x++ {
|
for x := i.Rect.Min.X; x < i.Rect.Max.X; x++ {
|
||||||
argb := uint32(i.Pix[p + 3]) << 24 // A
|
argb := uint32(i.Pix[p+3]) << 24 // A
|
||||||
argb |= uint32(i.Pix[p + 0]) << 16 // R
|
argb |= uint32(i.Pix[p+0]) << 16 // R
|
||||||
argb |= uint32(i.Pix[p + 1]) << 8 // G
|
argb |= uint32(i.Pix[p+1]) << 8 // G
|
||||||
argb |= uint32(i.Pix[p + 2]) // B
|
argb |= uint32(i.Pix[p+2]) // B
|
||||||
// the magic of conversion
|
// the magic of conversion
|
||||||
native := (*[4]byte)(unsafe.Pointer(&argb))
|
native := (*[4]byte)(unsafe.Pointer(&argb))
|
||||||
realbits[q + 0] = native[0]
|
realbits[q+0] = native[0]
|
||||||
realbits[q + 1] = native[1]
|
realbits[q+1] = native[1]
|
||||||
realbits[q + 2] = native[2]
|
realbits[q+2] = native[2]
|
||||||
realbits[q + 3] = native[3]
|
realbits[q+3] = native[3]
|
||||||
p += 4
|
p += 4
|
||||||
q += 4
|
q += 4
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
|
||||||
"image"
|
"image"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
|
@ -28,10 +28,10 @@ func areaView_drawRect(self C.id, rect C.struct_xrect) {
|
||||||
s := getSysData(self)
|
s := getSysData(self)
|
||||||
// no need to clear the clip rect; the NSScrollView does that for us (see the setDrawsBackground: call in objc_darwin.m)
|
// no need to clear the clip rect; the NSScrollView does that for us (see the setDrawsBackground: call in objc_darwin.m)
|
||||||
// rectangles in Cocoa are origin/size, not point0/point1; if we don't watch for this, weird things will happen when scrolling
|
// rectangles in Cocoa are origin/size, not point0/point1; if we don't watch for this, weird things will happen when scrolling
|
||||||
cliprect := image.Rect(int(rect.x), int(rect.y), int(rect.x + rect.width), int(rect.y + rect.height))
|
cliprect := image.Rect(int(rect.x), int(rect.y), int(rect.x+rect.width), int(rect.y+rect.height))
|
||||||
max := C.frame(self)
|
max := C.frame(self)
|
||||||
cliprect = image.Rect(0, 0, int(max.width), int(max.height)).Intersect(cliprect)
|
cliprect = image.Rect(0, 0, int(max.width), int(max.height)).Intersect(cliprect)
|
||||||
if cliprect.Empty() { // no intersection; nothing to paint
|
if cliprect.Empty() { // no intersection; nothing to paint
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
i := s.handler.Paint(cliprect)
|
i := s.handler.Paint(cliprect)
|
||||||
|
@ -42,10 +42,10 @@ func areaView_drawRect(self C.id, rect C.struct_xrect) {
|
||||||
|
|
||||||
func parseModifiers(e C.id) (m Modifiers) {
|
func parseModifiers(e C.id) (m Modifiers) {
|
||||||
const (
|
const (
|
||||||
_NSShiftKeyMask = 1 << 17
|
_NSShiftKeyMask = 1 << 17
|
||||||
_NSControlKeyMask = 1 << 18
|
_NSControlKeyMask = 1 << 18
|
||||||
_NSAlternateKeyMask = 1 << 19
|
_NSAlternateKeyMask = 1 << 19
|
||||||
_NSCommandKeyMask = 1 << 20
|
_NSCommandKeyMask = 1 << 20
|
||||||
)
|
)
|
||||||
|
|
||||||
mods := uintptr(C.modifierFlags(e))
|
mods := uintptr(C.modifierFlags(e))
|
||||||
|
@ -77,7 +77,7 @@ func areaMouseEvent(self C.id, e C.id, click bool, up bool) {
|
||||||
}
|
}
|
||||||
me.Modifiers = parseModifiers(e)
|
me.Modifiers = parseModifiers(e)
|
||||||
which := uint(C.buttonNumber(e)) + 1
|
which := uint(C.buttonNumber(e)) + 1
|
||||||
if which == 3 { // swap middle and right button numbers
|
if which == 3 { // swap middle and right button numbers
|
||||||
which = 2
|
which = 2
|
||||||
} else if which == 2 {
|
} else if which == 2 {
|
||||||
which = 3
|
which = 3
|
||||||
|
@ -89,22 +89,22 @@ func areaMouseEvent(self C.id, e C.id, click bool, up bool) {
|
||||||
// this already works the way we want it to so nothing special needed like with Windows and GTK+
|
// this already works the way we want it to so nothing special needed like with Windows and GTK+
|
||||||
me.Count = uint(C.clickCount(e))
|
me.Count = uint(C.clickCount(e))
|
||||||
} else {
|
} else {
|
||||||
which = 0 // reset for Held processing below
|
which = 0 // reset for Held processing below
|
||||||
}
|
}
|
||||||
// the docs do say don't use this for tracking (mouseMoved:) since it returns the state now, and mouse move events work by tracking, but as far as I can tell dragging the mouse over the inactive window does not generate an event on Mac OS X, so :/ (tracking doesn't touch dragging anyway except during mouseEntered: and mouseExited:, which we don't handle, and the only other tracking message, cursorChanged:, we also don't handle (yet...? need to figure out if this is how to set custom cursors or not), so)
|
// the docs do say don't use this for tracking (mouseMoved:) since it returns the state now, and mouse move events work by tracking, but as far as I can tell dragging the mouse over the inactive window does not generate an event on Mac OS X, so :/ (tracking doesn't touch dragging anyway except during mouseEntered: and mouseExited:, which we don't handle, and the only other tracking message, cursorChanged:, we also don't handle (yet...? need to figure out if this is how to set custom cursors or not), so)
|
||||||
held := C.pressedMouseButtons()
|
held := C.pressedMouseButtons()
|
||||||
if which != 1 && (held & 1) != 0 { // button 1
|
if which != 1 && (held&1) != 0 { // button 1
|
||||||
me.Held = append(me.Held, 1)
|
me.Held = append(me.Held, 1)
|
||||||
}
|
}
|
||||||
if which != 2 && (held & 4) != 0 { // button 2; mind the swap
|
if which != 2 && (held&4) != 0 { // button 2; mind the swap
|
||||||
me.Held = append(me.Held, 2)
|
me.Held = append(me.Held, 2)
|
||||||
}
|
}
|
||||||
if which != 3 && (held & 2) != 0 { // button 3
|
if which != 3 && (held&2) != 0 { // button 3
|
||||||
me.Held = append(me.Held, 3)
|
me.Held = append(me.Held, 3)
|
||||||
}
|
}
|
||||||
held >>= 3
|
held >>= 3
|
||||||
for i := uint(4); held != 0; i++ {
|
for i := uint(4); held != 0; i++ {
|
||||||
if which != i && (held & 1) != 0 {
|
if which != i && (held&1) != 0 {
|
||||||
me.Held = append(me.Held, i)
|
me.Held = append(me.Held, i)
|
||||||
}
|
}
|
||||||
held >>= 1
|
held >>= 1
|
||||||
|
@ -173,8 +173,8 @@ func areaView_flagsChanged(self C.id, e C.id) {
|
||||||
// Mac OS X sends this event on both key up and key down.
|
// Mac OS X sends this event on both key up and key down.
|
||||||
// Fortunately -[e keyCode] IS valid here, so we can simply map from key code to Modifiers, get the value of [e modifierFlags], and check if the respective bit is set or not — that will give us the up/down state
|
// Fortunately -[e keyCode] IS valid here, so we can simply map from key code to Modifiers, get the value of [e modifierFlags], and check if the respective bit is set or not — that will give us the up/down state
|
||||||
keyCode := uintptr(C.keyCode(e))
|
keyCode := uintptr(C.keyCode(e))
|
||||||
mod, ok := keycodeModifiers[keyCode] // comma-ok form to avoid adding entries
|
mod, ok := keycodeModifiers[keyCode] // comma-ok form to avoid adding entries
|
||||||
if !ok { // unknown modifier; ignore
|
if !ok { // unknown modifier; ignore
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ke.Modifiers = parseModifiers(e)
|
ke.Modifiers = parseModifiers(e)
|
||||||
|
|
Loading…
Reference in New Issue