Added autofocus to edit dialogs first editline, added tab support for selecting next focusable element in edit dialogs, made valid? method be called in edit dialogs when fields change, simulator robot can now strafe side to side

This commit is contained in:
2021-02-11 09:28:04 -06:00
parent 3cc4c204a7
commit 75d6de0b00
6 changed files with 112 additions and 5 deletions

View File

@@ -57,6 +57,38 @@ module TAC
def try_commit
end
def focus_next_element
elements = []
_deep_dive_interactive_elements(@dialog_content, elements)
element_index = elements.find_index(self.focused)
if element_index && elements.size.positive?
element = elements[element_index + 1]
element ||= elements.first
if element
request_focus(element)
end
end
end
def _deep_dive_interactive_elements(element, list)
element.children.each do |child|
if child.visible? && child.is_a?(CyberarmEngine::Element::EditLine) ||
child.is_a?(CyberarmEngine::Element::EditBox) ||
child.is_a?(CyberarmEngine::Element::CheckBox) ||
child.is_a?(CyberarmEngine::Element::ToggleButton) ||
child.is_a?(CyberarmEngine::Element::ListBox)
list << child
elsif child.visible? && child.is_a?(CyberarmEngine::Element::Container)
_deep_dive_interactive_elements(child, list)
end
end
end
def draw
@previous_state.draw
Gosu.flush
@@ -84,6 +116,8 @@ module TAC
try_commit
when Gosu::KB_ESCAPE
close
when Gosu::KB_TAB
focus_next_element
end
end