From 11c9bd850b1d1d629b988bfab5e7cc515a495bee Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 3 Jan 2025 12:33:48 +0100 Subject: Remove numpad keys from the main layout When the numpad is visible, remove the digits and arithmetic symbols from the main layout. Similarly to when the number row is added. --- srcs/juloo.keyboard2/LayoutModifier.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'srcs') diff --git a/srcs/juloo.keyboard2/LayoutModifier.java b/srcs/juloo.keyboard2/LayoutModifier.java index bda86c8..7220634 100644 --- a/srcs/juloo.keyboard2/LayoutModifier.java +++ b/srcs/juloo.keyboard2/LayoutModifier.java @@ -33,12 +33,20 @@ public final class LayoutModifier extra_keys.put(KeyValue.getKeyByName("config"), KeyboardData.PreferredPos.ANYWHERE); extra_keys.putAll(globalConfig.extra_keys_param); extra_keys.putAll(globalConfig.extra_keys_custom); - // The number row is added after the modification pass to avoid adding extra keys to it. + // Number row and numpads are added after the modification pass to allow + // removing the number keys from the main layout. KeyboardData.Row added_number_row = null; - if (globalConfig.add_number_row && !globalConfig.show_numpad) + KeyboardData added_numpad = null; + if (globalConfig.show_numpad) + { + added_numpad = modify_numpad(num_pad, kw); + remove_keys.addAll(added_numpad.getKeys().keySet()); + } + else if (globalConfig.add_number_row) // The numpad removes the number row + { added_number_row = modify_number_row(number_row, kw); - if (added_number_row != null) remove_keys.addAll(added_number_row.getKeys(0).keySet()); + } // Add the bottom row before computing the extra keys if (kw.bottom_row) kw = kw.insert_row(bottom_row, kw.rows.size()); @@ -64,12 +72,13 @@ public final class LayoutModifier return modify_key(key); } }); - if (globalConfig.show_numpad) - kw = kw.addNumPad(modify_numpad(num_pad, kw)); + if (added_numpad != null) + kw = kw.addNumPad(added_numpad); // Add extra keys that are not on the layout (including 'loc' keys) extra_keys_keyset.removeAll(kw_keys); if (extra_keys.size() > 0) kw = kw.addExtraKeys(extra_keys.entrySet().iterator()); + // Avoid adding extra keys to the number row if (added_number_row != null) kw = kw.insert_row(added_number_row, 0); return kw; -- cgit v1.2.3