Not sure if you're looking for this or just keyboard presses but it might
help

I picked this code up off somewhere (android I think) and adapted it from
the java
It works fine in a test app
Other than that if you're after key presses you might simply construct a
kepress listener
-- not sure if this would work 
correctiondialog.SetOnKeyListener(new
Activity1.EnterListener(this,edtext,mystr));

unless anyone else knows better 


======= // here's my gesture listener stuff


// these four lines are declared in the oncreate method - as you can see I
am using it with a tabhost
// you'll have to play around
private GestureDetector gestureScannerA;
private GestureListener gestureListenerA
gestureListenerA = new GestureListener(TabHost, this, 0, this.TabHost);
gestureScannerA = new GestureDetector(this, gestureListenerA);

        //=======================gesture listener stuff
        public class GestureListener : GestureDetector.IOnGestureListener
        {
            private readonly View view;
            private Context cntxt;
            private TabHost TH;
            private static int SWIPE_MAX_OFF_PATH = 250;
            private static int SWIPE_MIN_DISTANCE = 100;
            private static int SWIPE_THRESHOLD_VELOCITY = 150;

            public GestureListener(View view, Context Cntxt, int currtab,
TabHost th)
            {
                this.view = view;
                this.cntxt = Cntxt;
                this.TH = th;
            }
            //public IntPtr Handle
            public IntPtr Handle
            {
                get { throw new NotImplementedException(); }
            }


            public bool OnDown(MotionEvent e)
            {
                //      Toast.MakeText(cntxt, "down swipe",
ToastLength.Short).Show();
                // view.Text = "- DOWN -";
                return true;
            }


            public bool OnFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY)
            {
                try
                {
                    if (System.Math.Abs(e1.GetY() - e2.GetY()) >
SWIPE_MAX_OFF_PATH)
                        return false;
                    // right to left swipe
                    if (e1.GetX() - e2.GetX() > SWIPE_MIN_DISTANCE &&
System.Math.Abs(velocityX) > SWIPE_THRESHOLD_VELOCITY)
                    {

                        //    Toast.MakeText(view.Context, "Left Swipe",
ToastLength.Short).Show();

                        if (TH.CurrentTab == 4)
                        {
                            TH.CurrentTab = 0;
                        }
                        else
                        {

                            TH.CurrentTab = TH.CurrentTab + 1;
                        }



                        //TabHost.CurrentTab=1;
                    }

                    else if (e2.GetX() - e1.GetX() > SWIPE_MIN_DISTANCE &&
System.Math.Abs(velocityX) > SWIPE_THRESHOLD_VELOCITY)
                        //  Toast.MakeText(view.Context, "Right Swipe",
ToastLength.Short).Show();
                        if (TH.CurrentTab == 0)
                        {
                            TH.CurrentTab = 4;
                        }
                        else
                        {
                            TH.CurrentTab = TH.CurrentTab - 1;
                        }

                }
                catch (System.Exception e)
                {

                    Toast.MakeText(view.Context, "" + e.ToString(),
ToastLength.Long).Show();
                    // nothing
                }
                return false;
            }


            public void OnLongPress(MotionEvent e)
            {
                //      Toast.MakeText(cntxt, "Long press",
ToastLength.Short).Show();
                //view.Text = "- LONG PRESS -";
            }

            public bool OnScroll(MotionEvent e1, MotionEvent e2, float
distanceX, float distanceY)
            {
                //      Toast.MakeText(cntxt, "this si a fling or  scroll",
ToastLength.Short).Show();
                //view.Text = "- FLING -";
                return true;
            }

            public void OnShowPress(MotionEvent e)
            {
                //      Toast.MakeText(cntxt, "a show pres?",
ToastLength.Short).Show();
                //view.Text = "- SHOW PRESS -";
            }

            public bool OnSingleTapUp(MotionEvent e)
            {
                //view.Text = "- SINGLE TAP UP -";
                //      Toast.MakeText(cntxt, "single up tap",
ToastLength.Short).Show();
                return true;
            }
        }

        //=======================end of gesture listener stuff

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of was
Sent: 19 August 2011 10:13
To: [email protected]
Subject: [mono-android] Detecting Keystokes

How can I detect soft and hard keyboard strokes in mfa?

Regards...Andrew

--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Detecting-Keystokes-tp4714994p
4714994.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to