Skip to content

Commit b098f06

Browse files
cmot17hecrj
authored andcommitted
Fix issue with text selection in text_input widget
1 parent 20177e4 commit b098f06

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

native/src/widget/text_input.rs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -335,29 +335,27 @@ where
335335
let text_layout = layout.children().next().unwrap();
336336
let target = position.x - text_layout.bounds().x;
337337

338-
if target > 0.0 {
339-
let value = if self.is_secure {
340-
self.value.secure()
341-
} else {
342-
self.value.clone()
343-
};
344-
345-
let position = renderer
346-
.find_cursor_position(
347-
text_layout.bounds(),
348-
self.font,
349-
self.size,
350-
&value,
351-
&self.state,
352-
target,
353-
)
354-
.unwrap_or(0);
355-
356-
self.state.cursor.select_range(
357-
self.state.cursor.start(&value),
358-
position,
359-
);
360-
}
338+
let value = if self.is_secure {
339+
self.value.secure()
340+
} else {
341+
self.value.clone()
342+
};
343+
344+
let position = renderer
345+
.find_cursor_position(
346+
text_layout.bounds(),
347+
self.font,
348+
self.size,
349+
&value,
350+
&self.state,
351+
target,
352+
)
353+
.unwrap_or(0);
354+
355+
self.state.cursor.select_range(
356+
self.state.cursor.start(&value),
357+
position,
358+
);
361359

362360
return event::Status::Captured;
363361
}

0 commit comments

Comments
 (0)