Fix issue with text selection in text_input widget

This commit is contained in:
cmot17 2021-10-24 08:57:14 -04:00 committed by Héctor Ramón Jiménez
parent 20177e423c
commit b098f06a29
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -335,29 +335,27 @@ where
let text_layout = layout.children().next().unwrap(); let text_layout = layout.children().next().unwrap();
let target = position.x - text_layout.bounds().x; let target = position.x - text_layout.bounds().x;
if target > 0.0 { let value = if self.is_secure {
let value = if self.is_secure { self.value.secure()
self.value.secure() } else {
} else { self.value.clone()
self.value.clone() };
};
let position = renderer let position = renderer
.find_cursor_position( .find_cursor_position(
text_layout.bounds(), text_layout.bounds(),
self.font, self.font,
self.size, self.size,
&value, &value,
&self.state, &self.state,
target, target,
) )
.unwrap_or(0); .unwrap_or(0);
self.state.cursor.select_range( self.state.cursor.select_range(
self.state.cursor.start(&value), self.state.cursor.start(&value),
position, position,
); );
}
return event::Status::Captured; return event::Status::Captured;
} }