From 29d892d2ffb5a0df1f7bdb170fa63b15230150d6 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 12 May 2014 11:34:24 -0400 Subject: [PATCH] Fixed Mac OS X Area mouse drags being reported outside the actual Area. --- area_darwin.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/area_darwin.go b/area_darwin.go index c5f0549..afb5b12 100644 --- a/area_darwin.go +++ b/area_darwin.go @@ -179,8 +179,11 @@ func areaMouseEvent(self C.id, e C.id, click bool, up bool) { s := getSysData(self) xp := C.getTranslatedEventPoint(self, e) me.Pos = image.Pt(int(xp.x), int(xp.y)) - // no need to check me.Pos; Cocoa won't send an event outside the Area - // TODO actually wrong; Cocoa will if we drag out of the window + // for the most part, Cocoa won't geenerate an event outside the Area... except when dragging outside the Area, so check for this + max := C.objc_msgSend_stret_rect_noargs(self, _frame) + if !me.Pos.In(image.Rect(0, 0, int(max.width), int(max.height))) { + return + } me.Modifiers = parseModifiers(e) which := uint(C.objc_msgSend_intret_noargs(e, _buttonNumber)) + 1 if which == 3 { // swap middle and right button numbers