diff options
Diffstat (limited to 'event.c')
-rw-r--r-- | event.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -117,6 +117,28 @@ mouseevent(Mouse m) return 0; wlock(&g->lock); + + /* Handle scrolling first */ + if(g->type == Gtextbox && m.buttons&24){ /* TODO: in the future it may apply to other things? */ + PropVal p = getprop(g, Pscroll, 0); + int lines = ((m.xy.y - g->content.min.y) / font->height); + if(lines < 1) + lines = 1; + + if(m.buttons&8) + p.scroll -= lines; + else if(m.buttons&16) + p.scroll += lines; + + if(p.scroll < 0) + p.scroll = 0; + + setprop(g, Pscroll, p, 0); + wunlock(&g->lock); + return 1; + } + + /* Then handle menus */ Event e; MenuSpec *ms = getprop(g, Pmenus, 0).menus; if(down >= 1 && down <= 3 && ms->menus[down-1] != nil){ @@ -139,6 +161,7 @@ mouseevent(Mouse m) return 1; } + /* Now handle general events */ if(!g->listening){ wunlock(&g->lock); return 0; |