Fixed Area mouse events being sent when something happens outside the Area itself.
This commit is contained in:
parent
bd907dadd8
commit
a01ffafba0
|
@ -143,6 +143,7 @@ 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
|
||||
me.Modifiers = parseModifiers(e)
|
||||
which := uint(C.objc_msgSend_intret_noargs(e, _buttonNumber)) + 1
|
||||
if which == 3 { // swap middle and right button numbers
|
||||
|
|
|
@ -105,6 +105,8 @@ func makeModifiers(state C.guint, m Modifiers) Modifiers {
|
|||
|
||||
// shared code for finishing up and sending a mouse event
|
||||
func finishMouseEvent(widget *C.GtkWidget, data C.gpointer, me MouseEvent, mb uint, x C.gdouble, y C.gdouble, state C.guint, gdkwindow *C.GdkWindow) {
|
||||
var areawidth, areaheight C.gint
|
||||
|
||||
s := (*sysData)(unsafe.Pointer(data))
|
||||
state = translateModifiers(state, gdkwindow)
|
||||
me.Modifiers = makeModifiers(state, 0)
|
||||
|
@ -126,6 +128,10 @@ func finishMouseEvent(widget *C.GtkWidget, data C.gpointer, me MouseEvent, mb ui
|
|||
me.Held = append(me.Held, 5)
|
||||
}
|
||||
me.Pos = image.Pt(int(x), int(y))
|
||||
C.gtk_widget_get_size_request(widget, &areawidth, &areaheight)
|
||||
if !me.Pos.In(image.Rect(0, 0, int(areawidth), int(areaheight))) { // outside the actual Area; no event
|
||||
return
|
||||
}
|
||||
repaint := s.handler.Mouse(me)
|
||||
if repaint {
|
||||
C.gtk_widget_queue_draw(widget)
|
||||
|
|
|
@ -358,6 +358,9 @@ func areaMouseEvent(s *sysData, button uint, up bool, count uint, wparam _WPARAM
|
|||
xpos += lparam._X()
|
||||
ypos += lparam._Y()
|
||||
me.Pos = image.Pt(int(xpos), int(ypos))
|
||||
if !me.Pos.In(image.Rect(0, 0, s.areawidth, s.areaheight)) { // outside the actual Area; no event
|
||||
return
|
||||
}
|
||||
if up {
|
||||
me.Up = button
|
||||
} else {
|
||||
|
|
2
todo.md
2
todo.md
|
@ -16,7 +16,7 @@ important things:
|
|||
- make gcc (Unix)/clang (Mac OS X) pedantic about warnings/errors; also -Werror
|
||||
- problem: cgo-generated files trip -Werror up; I can't seem to turn off unused argument warnings with the -Wall/-Wextra/-pedantic options
|
||||
- consolidate scroll view code in GTK+ and Mac OS X
|
||||
- make sure mouse events don't trigger if the control size is larger than the Area size and the mouse event happens outside the Area range on all platforms
|
||||
- make sure mouse events trigger when we move the mouse over an Area with a button held on OS X
|
||||
- area test time label weirdness
|
||||
- does not show anything past the date on windows
|
||||
- does not show initially on OS X; it shows up once you resize, and even shows up after you resize back to the original size
|
||||
|
|
Loading…
Reference in New Issue