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

Method set_text_value

src/engine.rs:5894–5908  ·  view source on GitHub ↗

Sets the text value for a text input element.

(&mut self, element_id: u32, value: &str)

Source from the content-addressed store, hash-verified

5892
5893 /// Sets the text value for a text input element.
5894 pub fn set_text_value(&mut self, element_id: u32, value: &str) {
5895 let state = self.text_edit_states
5896 .entry(element_id)
5897 .or_insert_with(crate::text_input::TextEditState::default);
5898 state.text = value.to_string();
5899 #[cfg(feature = "text-styling")]
5900 let max_pos = crate::text_input::styling::cursor_len(&state.text);
5901 #[cfg(not(feature = "text-styling"))]
5902 let max_pos = state.text.chars().count();
5903 if state.cursor_pos > max_pos {
5904 state.cursor_pos = max_pos;
5905 }
5906 state.selection_anchor = None;
5907 state.reset_blink();
5908 }
5909
5910 /// Returns the cursor position for a text input element, or 0 if not found.
5911 /// When text-styling is enabled, this returns the visual position.

Callers

nothing calls this directly

Calls 2

cursor_lenFunction · 0.85
reset_blinkMethod · 0.80

Tested by

no test coverage detected