June 13, 2016 Mouse wheel on the splitter = fun | ||||
---|---|---|---|---|
| ||||
I've recently added this to Coedit: the split between the widgets can be srolled and the mouse pointer follows. Then As I'm building a GUI framework in D I've added what's necessary to reproduce it in D. It's fun with free mouse wheels. https://vimeo.com/170517792 And it's stupid simple: struct Mouse { private OsWindowHandle _winHdl; /// Constructs an instance with the handle of the target window. this(OsWindowHandle winHdl) { _winHdl = winHdl; } /// Returns the mouse position as a point of int. Point!int position() const { Point!int result; version(linux) { int a,b; uint c; Window r,t; XQueryPointer(display, _winHdl, &r, &t, &a, &b, &result.x, &result.y, &c); return result; } } /// Sets the mouse position from a point. void position(T)(Point!T value) const if (isNumeric!T) { version(linux) { XWarpPointer(display, _winHdl, _winHdl, 0, 0, 0, 0, cast(int) value.x, cast(int) value.y); } else static assert(0); } } |
Copyright © 1999-2021 by the D Language Foundation