diff options
| author | Teddy Wing | 2018-09-24 15:22:21 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-09-24 15:22:21 +0200 | 
| commit | 8cf96771dc99212620a7252bca0db340992be3f6 (patch) | |
| tree | bbcd1929aa2e909debf43af1213e1e9d0aac03ea | |
| parent | 882dfbe6f0aad091613839841d2f54334e37b32e (diff) | |
| download | dome-key-map-8cf96771dc99212620a7252bca0db340992be3f6.tar.bz2 | |
run_key_action_for_mode(): Deactivate current mode using trigger
Enable mode deactivation. If there is a current mode, deactivate it if
the trigger pressed is the current mode's trigger.
Return a BS `KeyActionResult` just to satisfy the return type
requirements of the function. We should really clean this function up
and eliminate this return value, but we can't until we move map action
key simulator handling into Rust.
| -rw-r--r-- | src/cocoa_bridge.rs | 11 | 
1 files changed, 9 insertions, 2 deletions
| diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index 11dc1c9..5f6cee7 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -224,8 +224,15 @@ mode <play><up> {      let map = map_group.maps.get(trigger);      let mode = map_group.modes.get(trigger); -    if let Some(ref mut in_mode) = state.in_mode { -        if let Some(mode) = map_group.modes.get(in_mode) { +    if let Some(in_mode) = state.in_mode.clone() { +        if let Some(mode) = map_group.modes.get(&in_mode) { +            // Deactivate mode by pressing current mode trigger +            if &in_mode[..] == trigger { +                state.in_mode = None; + +                return Some(KeyActionResult::new(ActionKind::Mode)) +            } +              if let Some(map) = mode.get(trigger) {                  return match map.kind {                      MapKind::Map => { | 
