|
@@ -78,6 +78,39 @@ public class RadioGroup : View
|
|
|
LayoutStarted += RadioGroup_LayoutStarted;
|
|
|
|
|
|
InvertColorsOnPress = true;
|
|
|
+
|
|
|
+ MouseClick += RadioGroup_MouseClick;
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: Fix InvertColorsOnPress - only highlight the selected item
|
|
|
+
|
|
|
+ private void RadioGroup_MouseClick (object sender, MouseEventEventArgs e)
|
|
|
+ {
|
|
|
+ SetFocus ();
|
|
|
+
|
|
|
+ int boundsX = e.MouseEvent.X;
|
|
|
+ int boundsY = e.MouseEvent.Y;
|
|
|
+
|
|
|
+ int pos = _orientation == Orientation.Horizontal ? boundsX : boundsY;
|
|
|
+
|
|
|
+ int rCount = _orientation == Orientation.Horizontal
|
|
|
+ ? _horizontal.Last ().pos + _horizontal.Last ().length
|
|
|
+ : _radioLabels.Count;
|
|
|
+
|
|
|
+ if (pos < rCount)
|
|
|
+ {
|
|
|
+ int c = _orientation == Orientation.Horizontal
|
|
|
+ ? _horizontal.FindIndex (x => x.pos <= boundsX && x.pos + x.length - 2 >= boundsX)
|
|
|
+ : boundsY;
|
|
|
+
|
|
|
+ if (c > -1)
|
|
|
+ {
|
|
|
+ _cursor = SelectedItem = c;
|
|
|
+ SetNeedsDisplay ();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ e.Handled = true;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -162,47 +195,6 @@ public class RadioGroup : View
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <inheritdoc/>
|
|
|
- protected internal override bool OnMouseEvent (MouseEvent me)
|
|
|
- {
|
|
|
- base.OnMouseEvent (me);
|
|
|
- if (!me.Flags.HasFlag (MouseFlags.Button1Clicked))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if (!CanFocus)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- SetFocus ();
|
|
|
-
|
|
|
- int boundsX = me.X;
|
|
|
- int boundsY = me.Y;
|
|
|
-
|
|
|
- int pos = _orientation == Orientation.Horizontal ? boundsX : boundsY;
|
|
|
-
|
|
|
- int rCount = _orientation == Orientation.Horizontal
|
|
|
- ? _horizontal.Last ().pos + _horizontal.Last ().length
|
|
|
- : _radioLabels.Count;
|
|
|
-
|
|
|
- if (pos < rCount)
|
|
|
- {
|
|
|
- int c = _orientation == Orientation.Horizontal
|
|
|
- ? _horizontal.FindIndex (x => x.pos <= boundsX && x.pos + x.length - 2 >= boundsX)
|
|
|
- : boundsY;
|
|
|
-
|
|
|
- if (c > -1)
|
|
|
- {
|
|
|
- _cursor = SelectedItem = c;
|
|
|
- SetNeedsDisplay ();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
/// <inheritdoc/>
|
|
|
public override void OnDrawContent (Rectangle contentArea)
|
|
|
{
|