summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/FormsSeekBar.cs
blob: cb58fbd73cd048fada893e2a9980b4272b3af204 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using Android.Widget;
using Android.Content;
using Android.Views;


namespace Xamarin.Forms.Platform.Android
{
	internal class FormsSeekBar : SeekBar
	{
		public FormsSeekBar(Context context) : base(context)
		{
			//this should work, but it doesn't.
			DuplicateParentStateEnabled = false;
		}

		public override bool OnTouchEvent(MotionEvent e)
		{
			switch (e.Action)
			{
				case MotionEventActions.Down:
					isTouching = true;
					break;
				case MotionEventActions.Up:
					Pressed = false;
					break;
			}
				
			return base.OnTouchEvent(e);
		}

		public override bool Pressed
		{
			get
			{
				return base.Pressed;
			}
			set
			{
				if (isTouching)
				{
					base.Pressed = value;
					isTouching = value;
				}
					
			}
		}

		bool isTouching = false;
	}
}