iup_widget_focus.e 3.4 KB

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