From 2884d45f0f05fd19442aa2396c55fc97182d3afc Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 3 Apr 2014 23:52:26 -0400 Subject: Fixed mouse move events on Mac OS X not returning buttons right, I think: turns out I was sending the wrong message in. Now I have to figure out how to filter out mouse move messages; then I can really make sure this works right... --- area_darwin.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/area_darwin.go b/area_darwin.go index 2f93614..a0223e5 100644 --- a/area_darwin.go +++ b/area_darwin.go @@ -118,9 +118,12 @@ func areaView_isFlipped_acceptsFirstResponder(self C.id, sel C.SEL) C.BOOL { } var ( + _NSEvent = objc_getClass("NSEvent") + _modifierFlags = sel_getUid("modifierFlags") _buttonNumber = sel_getUid("buttonNumber") _clickCount = sel_getUid("clickCount") + _pressedMouseButtons = sel_getUid("pressedMouseButtons") ) func parseModifiers(e C.id) (m Modifiers) { @@ -168,7 +171,8 @@ func areaMouseEvent(self C.id, e C.id, click bool, up bool) { } else { which = 0 // reset for Held processing below } - held := C.objc_msgSend_uintret_noargs(e, _clickCount) + // pressedMouseButtons is a class method; calling objc_msgSend() directly with e as an argument on these will panic (in real Objective-C the compiler can detect [e pressedMouseButtons]) + held := C.objc_msgSend_uintret_noargs(_NSEvent, _pressedMouseButtons) if which != 1 && (held & 1) != 0 { // button 1 me.Held = append(me.Held, 1) } -- cgit v1.2.3