fix caret getting stuck as visible without focus when the text field pauses blinking while it is without focus
This commit is contained in:
@@ -73,7 +73,7 @@ impl Caret {
|
||||
{
|
||||
let handle = cx.subscribe(emitter, |state, _emitter, event, cx| match event {
|
||||
CaretNotify::PauseBlinking => {
|
||||
if state.interval.is_zero() {
|
||||
if state.interval.is_zero() || !state.has_focus {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ impl Caret {
|
||||
return is_focused;
|
||||
}
|
||||
|
||||
match (is_focused, was_focused) {
|
||||
match (was_focused, is_focused) {
|
||||
// Caret has a blinking interval, and gained focused.
|
||||
(true, false) => {
|
||||
(false, true) => {
|
||||
self.has_focus = true;
|
||||
self.paused = false;
|
||||
|
||||
@@ -112,7 +112,7 @@ impl Caret {
|
||||
true
|
||||
}
|
||||
// Caret has a blinking interval and lost focus
|
||||
(false, true) => {
|
||||
(true, false) => {
|
||||
self.has_focus = false;
|
||||
self.visible = false;
|
||||
self.paused = false;
|
||||
|
||||
@@ -1138,8 +1138,8 @@ impl<'app> EditableTextActionHandler<Context<'app, Self>> for EditableTextState
|
||||
window: &mut Window,
|
||||
cx: &mut Context<'app, Self>,
|
||||
) {
|
||||
let character_pos = self.index_for_pixel_point(text_position, window.line_height());
|
||||
if self.is_selecting && self.click_count == 1 {
|
||||
let character_pos = self.index_for_pixel_point(text_position, window.line_height());
|
||||
self.select_to(character_pos, cx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user