Use select
for click selection in outline
This gets rid of duplicated code.
This commit is contained in:
parent
a2478febc1
commit
347981201c
1 changed files with 2 additions and 12 deletions
|
@ -208,19 +208,9 @@ fn ElementOutlineItem(key: ElementKey, element: Rc<dyn Element>) -> View {
|
|||
div(
|
||||
class="element",
|
||||
on:click={
|
||||
let state_clone = state.clone();
|
||||
move |event: MouseEvent| {
|
||||
if event.shift_key() {
|
||||
state.selection.update(|sel| {
|
||||
if !sel.remove(&key) {
|
||||
sel.insert(key);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
state.selection.update(|sel| {
|
||||
sel.clear();
|
||||
sel.insert(key);
|
||||
});
|
||||
}
|
||||
state_clone.select(key, event.shift_key());
|
||||
event.stop_propagation();
|
||||
event.prevent_default();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue