pub fn gdk_key_to_key(key: &EventKey) -> Option<Key> {
    let alt_pressed = key.get_state().contains(ModifierType::MOD1_MASK);
    let control_pressed = key.get_state().contains(ModifierType::CONTROL_MASK);
    let shift_pressed = key.get_state().contains(ModifierType::SHIFT_MASK);
    let key =
        match to_key(key) {
            Some(key) => key,
            None => return None,
        };

    let control_constructor: fn(Key) -> Key =
        if control_pressed {
            |key| Control(Box::new(key))
        }
        else {
            |key| key
        };

    let alt_constructor: fn(Key) -> Key =
        if alt_pressed {
            |key| Alt(Box::new(key))
        }
        else {
            |key| key
        };

    let shift_constructor: fn(Key) -> Key =
        if shift_pressed && !is_char(&key) {
            |key| Shift(Box::new(key))
        }
        else {
            |key| key
        };

    Some(control_constructor(alt_constructor(shift_constructor(key))))
}
/// Convert a GDK key to an MG Key.
Convert a GDK key to an MG Key.
Convert a GDK key to an MG Key .
pub fn gdk_key_to_key(key: &EventKey) -> Option<Key> {
    let alt_pressed = key.get_state().contains(ModifierType::MOD1_MASK);
    let control_pressed = key.get_state().contains(ModifierType::CONTROL_MASK);
    let shift_pressed = key.get_state().contains(ModifierType::SHIFT_MASK);
    let key =
        match to_key(key) {
            Some(key) => key,
            None => return None,
        };
    let control_constructor: fn(Key) -> Key =
        if control_pressed {
            |key| Control(Box::new(key))
        }
        else {
            |key| key
        };
    let alt_constructor: fn(Key) -> Key =
        if alt_pressed {
            |key| Alt(Box::new(key))
        }
        else {
            |key| key
        };
    let shift_constructor: fn(Key) -> Key =
        if shift_pressed && !is_char(&key) {
            |key| Shift(Box::new(key))
        }
        else {
            |key| key
        };
    Some(control_constructor(alt_constructor(shift_constructor(key))))
}
pub fn gdk_key_to_key ( key : & EventKey ) -> Option < Key > { let alt_pressed = key . get_state ( ) . contains ( ModifierType :: MOD1_MASK ) ; let control_pressed = key . get_state ( ) . contains ( ModifierType :: CONTROL_MASK ) ; let shift_pressed = key . get_state ( ) . contains ( ModifierType :: SHIFT_MASK ) ; let key = match to_key ( key ) { Some ( key ) => key , None => return None , } ; let control_constructor : fn ( Key ) -> Key = if control_pressed { | key | Control ( Box :: new ( key ) ) } else { | key | key } ; let alt_constructor : fn ( Key ) -> Key = if alt_pressed { | key | Alt ( Box :: new ( key ) ) } else { | key | key } ; let shift_constructor : fn ( Key ) -> Key = if shift_pressed && ! is_char ( & key ) { | key | Shift ( Box :: new ( key ) ) } else { | key | key } ; Some ( control_constructor ( alt_constructor ( shift_constructor ( key ) ) ) ) }
Convert a GDK key to an MG Key.
Convert a GDK key to an MG Key .
key
&EventKey