When no lane is selected, the hotkeys add a new lane. When a lane is selected, those hotkeys modify the current lane. (It's very disorienting to click a lane, hit 'b', and see a new bike lane instead of the modified one.

This commit is contained in:
Dustin Carlino 2021-08-25 10:51:57 -07:00
parent 2443479ad2
commit f64cd89f26

View File

@ -541,7 +541,13 @@ fn make_main_panel(
.get(lt)
.expect("lane_type button should have been cached")
.clone()
.hotkey(key.map(|k| k.into()))
// When we're modifying an existing lane, hotkeys change the lane, not add
// new lanes.
.hotkey(if selected_lane.is_none() {
key.map(|k| k.into())
} else {
None
})
.build_widget(ctx, format!("add {}", lt.short_name()))
.centered_vert()
})
@ -634,12 +640,13 @@ fn make_main_panel(
Widget::row(
lane_types
.iter()
.map(|(lt, _key)| {
.map(|(lt, key)| {
let lt = *lt;
let mut btn = lane_type_buttons
.get(&lt)
.expect("lane_type button should have been cached")
.clone();
.clone()
.hotkey(key.map(|k| k.into()));
if current_lt == Some(lt) {
// If the selected lane is already this type, we can't change it. Hopefully no need to