MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / change_focus

Method change_focus

src/engine.rs:5796–5825  ·  view source on GitHub ↗

Internal: changes focus, firing on_unfocus on old and on_focus on new.

(&mut self, new_id: u32)

Source from the content-addressed store, hash-verified

5794
5795 /// Internal: changes focus, firing on_unfocus on old and on_focus on new.
5796 pub(crate) fn change_focus(&mut self, new_id: u32) {
5797 let old_id = self.focused_element_id;
5798 if old_id == new_id {
5799 return;
5800 }
5801 self.focused_element_id = new_id;
5802 if new_id == 0 {
5803 self.focus_from_keyboard = false;
5804 }
5805
5806 // Fire on_unfocus on old element
5807 if old_id != 0 {
5808 if let Some(item) = self.layout_element_map.get_mut(&old_id) {
5809 let id_copy = item.element_id.clone();
5810 if let Some(ref mut callback) = item.on_unfocus_fn {
5811 callback(id_copy);
5812 }
5813 }
5814 }
5815
5816 // Fire on_focus on new element
5817 if new_id != 0 {
5818 if let Some(item) = self.layout_element_map.get_mut(&new_id) {
5819 let id_copy = item.element_id.clone();
5820 if let Some(ref mut callback) = item.on_focus_fn {
5821 callback(id_copy);
5822 }
5823 }
5824 }
5825 }
5826
5827 /// Fire the on_press callback for the element with the given u32 ID.
5828 /// Used by screen reader action handling.

Callers 6

evalMethod · 0.80
set_pointer_stateMethod · 0.80
set_focusMethod · 0.80
clear_focusMethod · 0.80
cycle_focusMethod · 0.80
arrow_focusMethod · 0.80

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected