fix: Combo key picker and TD buttons visibility

- Combo picker: pass key index directly instead of relying on selected_key_index
- TD actions: use DarkButton for consistent visibility
- Combo Add: validation message when keys not picked

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mae PUGIN 2026-04-07 09:20:54 +02:00
parent 4cfe2fbb7b
commit 362b0c729c
3 changed files with 30 additions and 41 deletions

View file

@ -705,25 +705,21 @@ fn main() {
adv.set_new_leader_result_name(name); adv.set_new_leader_result_name(name);
} }
"combo-key1" | "combo-key2" => { "combo-key1" | "combo-key2" => {
// For combo key picking, the user clicked on the keyboard view. // code = key index from the mini keyboard in the popup
// The selected key index tells us which physical key was clicked. let keys = keys_arc.borrow();
let key_idx = w.global::<KeymapBridge>().get_selected_key_index(); let idx = code as usize;
if key_idx >= 0 { if idx < keys.len() {
let keys = keys_arc.borrow(); let kp = &keys[idx];
let idx = key_idx as usize; let adv = w.global::<AdvancedBridge>();
if idx < keys.len() { let label = SharedString::from(format!("R{}C{}", kp.row, kp.col));
let kp = &keys[idx]; if target.as_str() == "combo-key1" {
let adv = w.global::<AdvancedBridge>(); adv.set_new_combo_r1(kp.row as i32);
let label = SharedString::from(format!("R{}C{}", kp.row, kp.col)); adv.set_new_combo_c1(kp.col as i32);
if target.as_str() == "combo-key1" { adv.set_new_combo_key1_name(label);
adv.set_new_combo_r1(kp.row as i32); } else {
adv.set_new_combo_c1(kp.col as i32); adv.set_new_combo_r2(kp.row as i32);
adv.set_new_combo_key1_name(label); adv.set_new_combo_c2(kp.col as i32);
} else { adv.set_new_combo_key2_name(label);
adv.set_new_combo_r2(kp.row as i32);
adv.set_new_combo_c2(kp.col as i32);
adv.set_new_combo_key2_name(label);
}
} }
} }
} }

View file

@ -132,9 +132,8 @@ export component KeySelector inherits Rectangle {
scale: parent.kb-scale; scale: parent.kb-scale;
data: keycap; data: keycap;
clicked(key-index) => { clicked(key-index) => {
KeymapBridge.select-key(key-index); // Pass key index as the code — dispatch reads keys_arc[code] for row/col
// The dispatch in main.rs handles combo-key1/combo-key2 KeySelectorBridge.select-keycode(key-index);
KeySelectorBridge.select-keycode(0); // trigger dispatch
KeymapBridge.key-selector-open = false; KeymapBridge.key-selector-open = false;
} }
} }

View file

@ -94,28 +94,22 @@ export component TabAdvanced inherits Rectangle {
for td in AdvancedBridge.tap-dances : Rectangle { for td in AdvancedBridge.tap-dances : Rectangle {
background: Theme.bg-primary; background: Theme.bg-primary;
border-radius: 4px; border-radius: 4px;
height: 30px;
HorizontalLayout { HorizontalLayout {
padding-left: 8px; padding-right: 8px; spacing: 4px; padding: 4px;
padding-left: 8px;
spacing: 4px;
alignment: start;
Text { text: "TD" + td.index; color: Theme.accent-purple; font-size: 11px; vertical-alignment: center; width: 35px; } Text { text: "TD" + td.index; color: Theme.accent-purple; font-size: 11px; vertical-alignment: center; width: 35px; }
for action[a-idx] in td.actions : Rectangle {
width: 60px;
height: 24px;
border-radius: 3px;
background: td-action-ta.has-hover ? Theme.button-hover : Theme.button-bg;
border-width: 1px;
border-color: Theme.button-border;
Text { text: action.name; color: Theme.fg-primary; font-size: 10px; horizontal-alignment: center; vertical-alignment: center; } for action[a-idx] in td.actions : DarkButton {
text: action.name;
td-action-ta := TouchArea { clicked => {
clicked => { AdvancedBridge.editing-td-index = td.index;
AdvancedBridge.editing-td-index = td.index; AdvancedBridge.editing-td-slot = a-idx;
AdvancedBridge.editing-td-slot = a-idx; KeymapBridge.selector-target = "td-action";
KeymapBridge.selector-target = "td-action"; KeymapBridge.key-selector-open = true;
KeymapBridge.key-selector-open = true;
}
mouse-cursor: pointer;
} }
} }
} }