Moved Mac OS X modifier flags constants to the Objective-C side for maximum safety.
This commit is contained in:
parent
5a67a81e0b
commit
bb8603ed4e
|
@ -60,25 +60,17 @@ func areaView_drawRect(self C.id, rect C.struct_xrect, data unsafe.Pointer) {
|
|||
}
|
||||
|
||||
func parseModifiers(e C.id) (m Modifiers) {
|
||||
const (
|
||||
// TODO define these on the Objective-C side
|
||||
_NSShiftKeyMask = 1 << 17
|
||||
_NSControlKeyMask = 1 << 18
|
||||
_NSAlternateKeyMask = 1 << 19
|
||||
_NSCommandKeyMask = 1 << 20
|
||||
)
|
||||
|
||||
mods := uintptr(C.modifierFlags(e))
|
||||
if (mods & _NSControlKeyMask) != 0 {
|
||||
mods := C.modifierFlags(e)
|
||||
if (mods & C.cNSControlKeyMask) != 0 {
|
||||
m |= Ctrl
|
||||
}
|
||||
if (mods & _NSAlternateKeyMask) != 0 {
|
||||
if (mods & C.cNSAlternateKeyMask) != 0 {
|
||||
m |= Alt
|
||||
}
|
||||
if (mods & _NSShiftKeyMask) != 0 {
|
||||
if (mods & C.cNSShiftKeyMask) != 0 {
|
||||
m |= Shift
|
||||
}
|
||||
if (mods & _NSCommandKeyMask) != 0 {
|
||||
if (mods & C.cNSCommandKeyMask) != 0 {
|
||||
m |= Super
|
||||
}
|
||||
return m
|
||||
|
|
|
@ -140,6 +140,12 @@ BOOL drawImage(void *pixels, intptr_t width, intptr_t height, intptr_t stride, i
|
|||
return success;
|
||||
}
|
||||
|
||||
// can't include the header file with these from the Go side since it's an Objective-C header file; keep them here to be safe
|
||||
const uintptr_t cNSShiftKeyMask = (uintptr_t) NSShiftKeyMask;
|
||||
const uintptr_t cNSControlKeyMask = (uintptr_t) NSControlKeyMask;
|
||||
const uintptr_t cNSAlternateKeyMask = (uintptr_t) NSAlternateKeyMask;
|
||||
const uintptr_t cNSCommandKeyMask = (uintptr_t) NSCommandKeyMask;
|
||||
|
||||
uintptr_t modifierFlags(id e)
|
||||
{
|
||||
return fromNSUInteger([toNSEvent(e) modifierFlags]);
|
||||
|
|
|
@ -102,6 +102,10 @@ extern struct xalignment alignmentInfoFrame(id);
|
|||
extern Class getAreaClass(void);
|
||||
extern id newArea(void *);
|
||||
extern BOOL drawImage(void *, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t);
|
||||
extern const uintptr_t cNSShiftKeyMask;
|
||||
extern const uintptr_t cNSControlKeyMask;
|
||||
extern const uintptr_t cNSAlternateKeyMask;
|
||||
extern const uintptr_t cNSCommandKeyMask;
|
||||
extern uintptr_t modifierFlags(id);
|
||||
extern struct xpoint getTranslatedEventPoint(id, id);
|
||||
extern intptr_t buttonNumber(id);
|
||||
|
|
Loading…
Reference in New Issue