mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Also implementing the ScrollBarView in the ComboBox of the ListsAndCombos scenario.
This commit is contained in:
@@ -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 ();
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user