public WidgetScrollBar() : base(0, 0) { var upButton = new WidgetButton(); upButton.SetParent(this); upButton.SetStyle(Globals.WidgetButtonStyles.GetStyle("scrollbar-up")); upButton.SetClickHandler(() => { SetValue(GetValue() - 1); }); upButton.SetRepeat(true); var downButton = new WidgetButton(); downButton.SetParent(this); downButton.SetStyle(Globals.WidgetButtonStyles.GetStyle("scrollbar-down")); downButton.SetClickHandler(() => { SetValue(GetValue() + 1); }); downButton.SetRepeat(true); var track = new WidgetButton(); track.SetParent(this); track.SetStyle(Globals.WidgetButtonStyles.GetStyle("scrollbar-track")); track.SetClickHandler((x, y) => { // The y value is in relation to the track, we need to add it's own Y value, // and compare against the current position of the handle y += mTrack.Y; if (y < mHandleButton.Y) { SetValue(GetValue() - 5); } else if (y >= mHandleButton.Y + mHandleButton.Height) { SetValue(GetValue() + 5); } }); track.SetRepeat(true); var handle = new WidgetScrollBarHandle(this); handle.SetParent(this); handle.Height = 100; Width = Math.Max(upButton.Width, downButton.Width); mUpButton = upButton; mDownButton = downButton; mTrack = track; mHandleButton = handle; Add(track); Add(upButton); Add(downButton); Add(handle); }