iup_widget_focus.e 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. deferred class IUP_WIDGET_FOCUS
  2. -- Command to handle the focus.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. set_focus: detachable IUP_WIDGET
  7. -- Sets the interface element that will receive the keyboard focus,
  8. -- i.e., the element that will receive keyboard events.
  9. --
  10. -- Returns: the identifier of the interface element that previously
  11. -- had the keyboard focus.
  12. local
  13. p: POINTER
  14. do
  15. p := int_set_focus(widget)
  16. if p /= default_pointer then
  17. Result := iup_open.get_widget_for_object(p)
  18. end
  19. end
  20. next_field: detachable IUP_WIDGET
  21. -- Shifts the focus to the next element that can have the focus. It is
  22. -- relative to the current element and does not depend on the element
  23. -- currently with the focus.
  24. --
  25. -- It will search for the next element first in the children, then in the
  26. -- brothers, then in the uncles and their children, and so on.
  27. --
  28. -- This sequence is not the same sequence used by the Tab key, which is
  29. -- dependent on the native system.
  30. --
  31. -- Returns: the element that received the focus or Void if not found.
  32. local
  33. p: POINTER
  34. do
  35. p := int_next_field(widget)
  36. if p /= default_pointer then
  37. Result := iup_open.get_widget_for_object(p)
  38. end
  39. end
  40. previous_field: detachable IUP_WIDGET
  41. -- Shifts the focus to the previous element that can have the focus. It
  42. -- is relative to the current element and does not depend on the element
  43. -- currently with the focus.
  44. --
  45. -- Returns: the element that received the focus or Void if not found.
  46. local
  47. p: POINTER
  48. do
  49. p := int_previous_field(widget)
  50. if p /= default_pointer then
  51. Result := iup_open.get_widget_for_object(p)
  52. end
  53. end
  54. feature {NONE}
  55. -- Internals
  56. int_set_focus (wgt: POINTER): POINTER
  57. external
  58. "C inline use %"eiffel-iup.h%""
  59. alias
  60. "return IupSetFocus ($wgt);"
  61. end
  62. int_next_field (wgt: POINTER): POINTER
  63. external
  64. "C inline use %"eiffel-iup.h%""
  65. alias
  66. "return IupNextField ($wgt);"
  67. end
  68. int_previous_field (wgt: POINTER): POINTER
  69. external
  70. "C inline use %"eiffel-iup.h%""
  71. alias
  72. "return IupPreviousField ($wgt);"
  73. end
  74. end
  75. -- The MIT License (MIT)
  76. -- Copyright (c) 2016, 2017, 2019 by German A. Arias
  77. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  78. -- of this software and associated documentation files (the "Software"), to deal
  79. -- in the Software without restriction, including without limitation the rights
  80. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  81. -- copies of the Software, and to permit persons to whom the Software is
  82. -- furnished to do so, subject to the following conditions:
  83. --
  84. -- The above copyright notice and this permission notice shall be included in
  85. -- all copies or substantial portions of the Software.
  86. --
  87. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  88. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  89. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  90. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  91. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  92. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  93. -- SOFTWARE.