summaryrefslogtreecommitdiff
path: root/event.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2024-02-17 16:42:00 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2024-02-17 16:42:00 +0000
commitd9a15e56d42e45f021c01d527df67863100840a7 (patch)
tree7e01ec814a1eae74db53522a2de40f1f81f3f43f /event.c
parentc51962a648b3f38fc378ad0081b1d1aa037142d5 (diff)
Implement scroll bar (not clickable yet) and sam-scrollingHEADfront
Diffstat (limited to 'event.c')
-rw-r--r--event.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/event.c b/event.c
index 4182d1c..81c923e 100644
--- a/event.c
+++ b/event.c
@@ -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;