4coder»Forums
4 posts
Custom Keybindings Not Working in Windows

Finally made the switch over to 4.1.8 from 4.1.6. I have a custom layer I created with some modal-type keybindings, mostly unchanged from the previous version. I pulled in a bunch (almost all) of the fleury layer because it had a bunch of neat features.

I implemented the layer in Linux; it works fine there. I pulled all the custom code over to Windows and it looks like the modal keybindings aren't getting picked up. I'm not using any of the default bindings nor loading the bindings file. As far as I can tell, I'm following the instructions from the new-ish getting started guide.

It starts out fine in basic editing mode (the 'keys_file' or 'keys_code' mapid), except anything not in the global mapping doesn't seem to be picked up. If I switch to one of my modes (using the command_lister), none of the keybindings work. I know the code is running by stepping through it with VS.

Here's how I'm setting up the keybindings:

    String_ID global_id = vars_save_string_lit("keys_global");
    String_ID file_id = vars_save_string_lit("keys_file");
    String_ID code_id = vars_save_string_lit("keys_code");
    String_ID file_base_id = vars_save_string_lit("keys_file_base");
    
    mapid_xcom = vars_save_string_lit("keys_xcom");
    mapid_command = vars_save_string_lit("keys_command");
    mapid_insert = vars_save_string_lit("keys_insert");
    
    MappingScope();
    SelectMapping(mapping);
    
    SelectMap(global_id);
    BindCore(fleury_startup, CoreCode_Startup);
    BindCore(default_try_exit, CoreCode_TryExit);
    
    BindCore(clipboard_record_clip, CoreCode_NewClipboardContents);
    Bind(modal_to_xcom, KeyCode_X, KeyCode_Control);
    ....
    Bind(exit_4coder,KeyCode_F4, KeyCode_Alt);
    BindMouseWheel(mouse_wheel_scroll);
    BindMouseWheel(mouse_wheel_change_face_size, KeyCode_Control);
    
    SelectMap(mapid_xcom);
    BindCore(default_try_exit, CoreCode_TryExit);
    Bind(modal_to_command, KeyCode_Escape);
    Bind(modal_to_command, KeyCode_G);
    ....
    Bind(MODAL(close_build_panel),             KeyCode_Comma, KeyCode_Alt);
    
    SelectMap(file_base_id);
    ParentMap(global_id);
    BindMouse(click_set_cursor_and_mark, MouseCode_Left);
    BindMouseRelease(click_set_cursor, MouseCode_Left);
    BindCore(click_set_cursor_and_mark, CoreCode_ClickActivateView);
    BindMouseMove(click_set_cursor_if_lbutton);
    Bind(delete_char,            KeyCode_Delete);
    ....
    Bind(view_jump_list_with_lister,  KeyCode_Period, KeyCode_Control, KeyCode_Shift);
    
    SelectMap(mapid_command);
    ParentMap(file_base_id);
    Bind(modal_to_insert, KeyCode_Escape);
    Bind(f4_home, KeyCode_A);
    Bind(move_left,              KeyCode_B);
    ....
    Bind(f4_open_project, KeyCode_O, KeyCode_Alt);
    
    SelectMap(file_id);
    ParentMap(file_base_id);
    BindTextInput(write_text_input);
    Bind(modal_to_command, KeyCode_Escape);
    
    SelectMap(code_id);
    ParentMap(file_id);
    BindTextInput(write_text_and_auto_indent);
    Bind(move_left_alpha_numeric_boundary,           KeyCode_Left, KeyCode_Control);
    Bind(move_right_alpha_numeric_boundary,          KeyCode_Right, KeyCode_Control);
    ....
    Bind(write_zero_struct,          KeyCode_0, KeyCode_Control);

Anyone know what I'm missing here?

Simon Anciaux
1340 posts
Custom Keybindings Not Working in Windows

Could you share the complete platform layer so I can try to compile and run it ?

Have you tried setting a breakpoint in default_view_input_handler and step in default_implicit_map to verify that map ids are set properly ?

4 posts
Custom Keybindings Not Working in Windows

I figured out my issue. I forgot to copy over the modified 4coder_default_framework.cpp file (as per the getting started guide).

Thank you for your help.