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:
parent
fe0b72e93c
commit
91de9fcd63
|
@ -28,11 +28,10 @@ int pl_hitscrollbar(Panel *g, Mouse *m){
|
||||||
size=subpt(g->r.max, g->r.min);
|
size=subpt(g->r.max, g->r.min);
|
||||||
pl_interior(g->state, &ul, &size);
|
pl_interior(g->state, &ul, &size);
|
||||||
oldstate=g->state;
|
oldstate=g->state;
|
||||||
if(m->buttons&OUT && m->buttons&7){
|
if(!(g->flags & USERFL) && (m->buttons&OUT || !ptinrect(m->xy, g->r))){
|
||||||
if(m->xy.y<g->r.min.y) m->xy.y=g->r.min.y;
|
m->buttons&=~OUT;
|
||||||
if(m->xy.y>=g->r.max.y) m->xy.y=g->r.max.y-1;
|
g->state=UP;
|
||||||
if(ptinrect(m->xy, g->r))
|
goto out;
|
||||||
m->buttons&=~OUT;
|
|
||||||
}
|
}
|
||||||
if(sp->dir==HORIZ){
|
if(sp->dir==HORIZ){
|
||||||
pos=m->xy.x-ul.x;
|
pos=m->xy.x-ul.x;
|
||||||
|
@ -71,6 +70,7 @@ int pl_hitscrollbar(Panel *g, Mouse *m){
|
||||||
pos, len);
|
pos, len);
|
||||||
g->state=UP;
|
g->state=UP;
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
if(oldstate!=g->state) pldraw(g, g->b);
|
if(oldstate!=g->state) pldraw(g, g->b);
|
||||||
return g->state==DOWN;
|
return g->state==DOWN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ void mkpanels(void){
|
||||||
cururl=pllabel(p, PACKE|EXPAND, "---");
|
cururl=pllabel(p, PACKE|EXPAND, "---");
|
||||||
plplacelabel(cururl, PLACEW);
|
plplacelabel(cururl, PLACEW);
|
||||||
p=plgroup(root, PACKN|EXPAND);
|
p=plgroup(root, PACKN|EXPAND);
|
||||||
bar=plscrollbar(p, PACKW);
|
bar=plscrollbar(p, PACKW|USERFL);
|
||||||
text=pltextview(p, PACKE|EXPAND, Pt(0, 0), 0, dolink);
|
text=pltextview(p, PACKE|EXPAND, Pt(0, 0), 0, dolink);
|
||||||
plscroll(text, 0, bar);
|
plscroll(text, 0, bar);
|
||||||
plgrabkb(cmd);
|
plgrabkb(cmd);
|
||||||
|
|
Loading…
Reference in a new issue