Also implementing the ScrollBarView in the ComboBox of the ListsAndCombos scenario.

This commit is contained in:
BDisp
2021-01-17 00:47:32 +00:00
parent 58c2509772
commit 0f038c76e1
2 changed files with 29 additions and 2 deletions

View File

@@ -210,7 +210,7 @@ namespace Terminal.Gui {
if (source == null)
return;
if (top < 0 || (source.Count > 0 && top >= source.Count))
if (value < 0 || (source.Count > 0 && value >= source.Count))
throw new ArgumentException ("value");
top = value;
SetNeedsDisplay ();
@@ -227,7 +227,7 @@ namespace Terminal.Gui {
if (source == null)
return;
if (left < 0 || (Maxlength > 0 && left >= Maxlength))
if (value < 0 || (Maxlength > 0 && value >= Maxlength))
throw new ArgumentException ("value");
left = value;
SetNeedsDisplay ();

View File

@@ -83,6 +83,33 @@ namespace UICatalog.Scenarios {
comboBox.SelectedItemChanged += (ListViewItemEventArgs text) => lbComboBox.Text = items[comboBox.SelectedItem];
Win.Add (lbComboBox, comboBox);
var scrollBarCbx = new ScrollBarView (comboBox.Subviews [1], true);
scrollBarCbx.ChangedPosition += () => {
((ListView)comboBox.Subviews [1]).TopItem = scrollBarCbx.Position;
if (((ListView)comboBox.Subviews [1]).TopItem != scrollBarCbx.Position) {
scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
}
comboBox.SetNeedsDisplay ();
};
scrollBarCbx.OtherScrollBarView.ChangedPosition += () => {
((ListView)comboBox.Subviews [1]).LeftItem = scrollBarCbx.OtherScrollBarView.Position;
if (((ListView)comboBox.Subviews [1]).LeftItem != scrollBarCbx.OtherScrollBarView.Position) {
scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
}
comboBox.SetNeedsDisplay ();
};
comboBox.DrawContent += (e) => {
scrollBarCbx.Size = comboBox.Source.Count + 1;
scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
scrollBarCbx.OtherScrollBarView.Size = ((ListView)comboBox.Subviews [1]).Maxlength;
scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
scrollBarCbx.Refresh ();
};
var btnMoveUp = new Button ("Move _Up") {
X = 1,
Y = Pos.Bottom(lbListView),