mirror of https://github.com/lapce/lapce.git
Fix rebase mistake
This commit is contained in:
parent
79aafd6c9f
commit
b7e49d330b
|
@ -727,12 +727,6 @@ pub fn value(
|
|||
fn get_key(&self) -> String {
|
||||
format!("{}.{}", self.kind, self.name.to_kebab_case())
|
||||
}
|
||||
|
||||
fn update_value(&mut self, ctx: &mut EventCtx, value: serde_json::Value) {
|
||||
self.value = value;
|
||||
self.value_changed = true;
|
||||
self.last_idle_timer = ctx.request_timer(Duration::from_millis(300));
|
||||
}
|
||||
}
|
||||
|
||||
impl KeyPressFocus for LapceSettingsItemKeypress {
|
||||
|
@ -793,35 +787,13 @@ fn event(
|
|||
) {
|
||||
if let Some(input) = self.input_widget.as_mut() {
|
||||
match event {
|
||||
Event::KeyDown(key_event) => {
|
||||
let mut f = LapceSettingsItemKeypress {
|
||||
input: self.input.clone(), // Clone so we can check for change
|
||||
cursor: self.cursor,
|
||||
};
|
||||
let mut_keypress = Arc::make_mut(&mut data.keypress);
|
||||
mut_keypress.key_down(ctx, key_event, &mut f, env);
|
||||
self.cursor = f.cursor;
|
||||
if f.input != self.input {
|
||||
self.input = f.input;
|
||||
let new_value = match &self.value {
|
||||
serde_json::Value::Number(_n) => {
|
||||
if let Ok(new_n) = self.input.parse::<i64>() {
|
||||
serde_json::json!(new_n)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
serde_json::Value::String(_s) => {
|
||||
serde_json::json!(self.input)
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
self.update_value(ctx, new_value);
|
||||
}
|
||||
}
|
||||
|
||||
Event::Wheel(_) => {}
|
||||
|
||||
_ => {
|
||||
input.event(ctx, event, data, env);
|
||||
}
|
||||
}
|
||||
}
|
||||
match event {
|
||||
Event::MouseDown(mouse_event) => {
|
||||
// ctx.request_focus();
|
||||
let input = self.input.clone();
|
||||
|
@ -832,9 +804,7 @@ fn event(
|
|||
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||
.text_color(
|
||||
data.config
|
||||
.get_color_unchecked(
|
||||
LapceTheme::EDITOR_FOREGROUND,
|
||||
)
|
||||
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||
.clone(),
|
||||
)
|
||||
.build()
|
||||
|
@ -856,8 +826,7 @@ fn event(
|
|||
self.cursor = hit.idx;
|
||||
}
|
||||
} else if let serde_json::Value::Bool(checked) = self.value {
|
||||
let rect =
|
||||
Size::new(self.checkbox_width, self.checkbox_width)
|
||||
let rect = Size::new(self.checkbox_width, self.checkbox_width)
|
||||
.to_rect()
|
||||
.with_origin(Point::new(
|
||||
0.0,
|
||||
|
@ -865,7 +834,10 @@ fn event(
|
|||
+ self.padding * 3.0,
|
||||
));
|
||||
if rect.contains(mouse_event.pos) {
|
||||
self.update_value(ctx, serde_json::json!(!checked));
|
||||
self.value = serde_json::json!(!checked);
|
||||
self.value_changed = true;
|
||||
self.last_idle_timer =
|
||||
ctx.request_timer(Duration::from_millis(300));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -892,10 +864,8 @@ fn event(
|
|||
Target::Widget(data.id),
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
input.event(ctx, event, data, env);
|
||||
}
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -958,14 +928,11 @@ fn update(
|
|||
}
|
||||
_ => return,
|
||||
};
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::UpdateSettingsFile(
|
||||
self.get_key(),
|
||||
new_value,
|
||||
),
|
||||
Target::Widget(data.id),
|
||||
));
|
||||
|
||||
self.value = new_value;
|
||||
self.value_changed = true;
|
||||
self.last_idle_timer =
|
||||
ctx.request_timer(Duration::from_millis(300));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue