Exemple #1
0
        /// <summary>
        /// Passes a touch location to this view for handling.
        /// </summary>
        /// <param name="scaledLoc">The location of the touch.</param>
        /// <returns>True if the UIElement was touched, false otherwise.</returns>
        public override bool HandleTouch(Vector2 scaledLoc, TouchLocation rawLocation, InputState input)
        {
            if (!base.HandleTouch(scaledLoc, rawLocation, input)) {
                return false; // touch wasn't for this view
            }

            if (input.TouchState.Count == 0) { // released our finger
                if (SelectedUIElement != null) {
                    if (OnElement) { // release our finger on the selected ui element
                        OnTapped(); // this counts as pressing the ui element
                    }
                    ResetSelected(); // make the ui element not pressed down anymore
                }
            } else {
                if (SelectedUIElement == null) { // we havn't selected an element yet, try to find one that we can select
                    if (rawLocation.State.HasFlag(TouchLocationState.Pressed)) {
                        // and this touch is the beginning of a touch
                        for (int i = 0; i < UIElements.Count; i++) {
                            UIElement uie = UIElements[UIElements.Count-i - 1];
                            if (uie.HandleTouch(scaledLoc, rawLocation, input)) {
                                // found the uielement that we pressed down on
                                OnElement = true;
                                SelectedUIElement = uie;
                                return true;
                            }
                        }
                    }
                } else {
                    // already have a ui element that we started our press in
                    // pass in the new coordinates to it
                    OnElement = SelectedUIElement.HandleTouch(scaledLoc, rawLocation, input);
                    return true;
                }
            }

            // went through all the elements in the view and couldn't find one that our press touches
            return true;
        }
 public UIElementTappedArgs(UIElement u)
 {
     Element = u;
     Arg = "";
     ObjectArg = null;
     ObjectArgExtra1 = null;
 }
Exemple #3
0
 public override void ResetSelected()
 {
     base.ResetSelected();
     if (SelectedUIElement != null) {
         SelectedUIElement.ResetSelected();
         SelectedUIElement = null;
     }
 }