mothra: fix scrollbar mouse grab behaviour

by default, scrollbars captured the mouse unless
all mouse buttons where released. this makes sense
in mothra main window, but makes drop down menus
with scrollbar unusable.

the patch lets one select the behaviour using the
USERFL-flag. if set, the scrollbar will capture
the mouse. if not set, scrollbar will release
the mouse when outside the scrollbar rect.
This commit is contained in:
cinap_lenrek 2012-06-30 19:49:51 +02:00
parent fe0b72e93c
commit 91de9fcd63
2 changed files with 6 additions and 6 deletions

View file

@ -28,11 +28,10 @@ int pl_hitscrollbar(Panel *g, Mouse *m){
size=subpt(g->r.max, g->r.min);
pl_interior(g->state, &ul, &size);
oldstate=g->state;
if(m->buttons&OUT && m->buttons&7){
if(m->xy.y<g->r.min.y) m->xy.y=g->r.min.y;
if(m->xy.y>=g->r.max.y) m->xy.y=g->r.max.y-1;
if(ptinrect(m->xy, g->r))
m->buttons&=~OUT;
if(!(g->flags & USERFL) && (m->buttons&OUT || !ptinrect(m->xy, g->r))){
m->buttons&=~OUT;
g->state=UP;
goto out;
}
if(sp->dir==HORIZ){
pos=m->xy.x-ul.x;
@ -71,6 +70,7 @@ int pl_hitscrollbar(Panel *g, Mouse *m){
pos, len);
g->state=UP;
}
out:
if(oldstate!=g->state) pldraw(g, g->b);
return g->state==DOWN;
}

View file

@ -179,7 +179,7 @@ void mkpanels(void){
cururl=pllabel(p, PACKE|EXPAND, "---");
plplacelabel(cururl, PLACEW);
p=plgroup(root, PACKN|EXPAND);
bar=plscrollbar(p, PACKW);
bar=plscrollbar(p, PACKW|USERFL);
text=pltextview(p, PACKE|EXPAND, Pt(0, 0), 0, dolink);
plscroll(text, 0, bar);
plgrabkb(cmd);