CellAddon.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. namespace Bitsplash.DatePicker
  6. {
  7. public class CellAddon : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler,IBeginDragHandler,IEndDragHandler,IDragHandler,IPointerDownHandler
  8. {
  9. DatePickerContent mParent;
  10. int mChildIndex;
  11. public void OnBeginDrag(PointerEventData eventData)
  12. {
  13. if (mParent != null)
  14. ((IDatePickerPrivate)mParent).RaiseStartSelection(mChildIndex);
  15. }
  16. public void OnDrag(PointerEventData eventData)
  17. {
  18. }
  19. public void OnEndDrag(PointerEventData eventData)
  20. {
  21. if (mParent != null)
  22. ((IDatePickerPrivate)mParent).EndSelection();
  23. }
  24. public void OnPointerClick(PointerEventData eventData)
  25. {
  26. }
  27. public void OnPointerDown(PointerEventData eventData)
  28. {
  29. if (mParent != null)
  30. ((IDatePickerPrivate)mParent).RaiseClick(mChildIndex);
  31. }
  32. public void OnPointerEnter(PointerEventData eventData)
  33. {
  34. if (eventData.pointerDrag != null)
  35. {
  36. var cellAddon = eventData.pointerDrag.GetComponent<CellAddon>();
  37. if (cellAddon != null && mParent != null)
  38. ((IDatePickerPrivate)mParent).RaiseSelectionEnter(mChildIndex, cellAddon.mChildIndex);
  39. }
  40. }
  41. public void OnPointerExit(PointerEventData eventData)
  42. {
  43. if (eventData.pointerDrag != null)
  44. {
  45. var cellAddon = eventData.pointerDrag.GetComponent<CellAddon>();
  46. if (cellAddon != null && mParent != null)
  47. ((IDatePickerPrivate)mParent).RaiseSelectionExit(mChildIndex, cellAddon.mChildIndex);
  48. }
  49. }
  50. public void SetParent(DatePickerContent parent,int childIndex)
  51. {
  52. mParent = parent;
  53. mChildIndex = childIndex;
  54. }
  55. // Start is called before the first frame update
  56. void Start()
  57. {
  58. }
  59. // Update is called once per frame
  60. void Update()
  61. {
  62. }
  63. }
  64. }