Sets the selection range for a text input element. `anchor` is where selection started, `cursor` is where it ends. When text-styling is enabled, these are visual positions.
(&mut self, element_id: u32, anchor: usize, cursor: usize)
| 5943 | /// `anchor` is where selection started, `cursor` is where it ends. |
| 5944 | /// When text-styling is enabled, these are visual positions. |
| 5945 | pub fn set_selection(&mut self, element_id: u32, anchor: usize, cursor: usize) { |
| 5946 | if let Some(state) = self.text_edit_states.get_mut(&element_id) { |
| 5947 | #[cfg(feature = "text-styling")] |
| 5948 | let max_pos = crate::text_input::styling::cursor_len(&state.text); |
| 5949 | #[cfg(not(feature = "text-styling"))] |
| 5950 | let max_pos = state.text.chars().count(); |
| 5951 | state.selection_anchor = Some(anchor.min(max_pos)); |
| 5952 | state.cursor_pos = cursor.min(max_pos); |
| 5953 | state.reset_blink(); |
| 5954 | } |
| 5955 | } |
| 5956 | |
| 5957 | /// Returns true if the given element ID is currently pressed. |
| 5958 | pub fn is_element_pressed(&self, element_id: u32) -> bool { |
nothing calls this directly
no test coverage detected