Fix scrolling functionality
Added Scroll(x, y) and Bump(x, y) functions to WebThing. Scroll moves
in pixels (or whatever unit measure Gtk uses), and Bump moves in default
scroll increments (like what you'd get if you used the arrow keys).
wtv.WebView.Open(uri);
return true;
}
+
+ public void Scroll(double x, double y) {
+ ScrolledWindow.Hadjustment.Value += x;
+ if (ScrolledWindow.Hadjustment.Value > ScrolledWindow.Hadjustment.Upper - ScrolledWindow.Hadjustment.PageSize)
+ ScrolledWindow.Hadjustment.Value = ScrolledWindow.Hadjustment.Upper - ScrolledWindow.Hadjustment.PageSize;
+ ScrolledWindow.Vadjustment.Value += y;
+ if (ScrolledWindow.Vadjustment.Value > ScrolledWindow.Vadjustment.Upper - ScrolledWindow.Vadjustment.PageSize)
+ ScrolledWindow.Vadjustment.Value = ScrolledWindow.Vadjustment.Upper - ScrolledWindow.Vadjustment.PageSize;
+ }
+
+ public void Bump(int x, int y) {
+ Scroll(x * ScrolledWindow.Hadjustment.StepIncrement, y * ScrolledWindow.Vadjustment.StepIncrement);
+ }
}
}
if (e.Event.State == Gdk.ModifierType.None) {
switch(e.Event.Key) {
case Gdk.Key.j:
- wt.ScrolledWindow.Vadjustment.Value += wt.ScrolledWindow.Vadjustment.StepIncrement;
+ wt.Bump(0, 1);
break;
case Gdk.Key.k:
- wt.ScrolledWindow.Vadjustment.Value -= wt.ScrolledWindow.Vadjustment.StepIncrement;
+ wt.Bump(0, -1);
break;
case Gdk.Key.l:
- wt.ScrolledWindow.Hadjustment.Value += wt.ScrolledWindow.Hadjustment.StepIncrement;
+ wt.Bump(1, 0);
break;
case Gdk.Key.h:
- wt.ScrolledWindow.Hadjustment.Value -= wt.ScrolledWindow.Hadjustment.StepIncrement;
+ wt.Bump(-1, 0);
break;
case Gdk.Key.r:
wv.Reload();