Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keybinding assignment in uilists (e.g., Map Notes) #55288

Merged
merged 1 commit into from
Feb 12, 2022

Conversation

haveric
Copy link
Contributor

@haveric haveric commented Feb 11, 2022

Summary

Bugfixes "Fix keybinding assignment in uilists (e.g., Map Notes)"

Purpose of change

Fixes #54778

Describe the solution

Reuse the input_context in uilists and create queues only from available hotkeys

Describe alternatives you've considered

  1. Pass input_context &ctx around a whole bunch. This felt more difficult than adding a class variable and the set category function
  2. Might be better code solutions and I am willing to take advice on anything that can be improved
  3. Leave broken

Testing

Created a bunch of map notes. Opened the map and viewed the List Notes menu. Compared the keybindings and tested the key functionalities within the menu.

This probably needs testing on other uilists to see how this affects them.

Additional context

Next step would be to evaluate if hotkey_queue &hotkey_queue::alphabets() is causing similar issues for npctalk and veh_interact. I suspect it is, but have not tested this yet. I can make this into another PR once verified it's an issue and this one is validated as working correctly.

Before change:
image

After change: (Note that keys such as f (find), j (down), k (up), E (Edit), M (Mark dangerous), D (Delete) do not show up
image

@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Feb 11, 2022
@ZhilkinSerg ZhilkinSerg merged commit ca6bc5d into CleverRaven:master Feb 12, 2022
@Maleclypse Maleclypse added Controls / Input Keyboard, mouse, keybindings, input UI, etc. <Bugfix> This is a fix for a bug (or closes open issue) labels Feb 14, 2022
@haveric haveric deleted the key-conflicts branch February 25, 2022 22:04
@Qrox
Copy link
Contributor

Qrox commented Mar 19, 2022

This has broken keycode mode.

for( int ch = 'A'; ch <= 'Z'; ++ch ) {
queue->codes_keychar.emplace_back( ch );

std::string available_hotkeys = ctxt.get_available_single_char_hotkeys();
Copy link
Contributor

@Qrox Qrox Mar 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_available_single_char_hotkeys only works for character mode. Not all characters returned from this call is a valid key code, and that's why get_available_single_char_hotkeys was specifically not used here.

Also, the removal of conflicting keys is actually handled by input_context::first_unassigned_hotkey, so this isn't a proper fix.

@@ -289,6 +289,7 @@ void uilist::init()
max_column_len = 0; // for calculating space for second column

input_category = "UILIST";
input_context ctxt( input_category, keyboard_mode::keychar );
Copy link
Contributor

@Qrox Qrox Mar 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only creates an input context in the local scope and has not effect on the ctxt member, so the ctxt member actually uses keycode mode when filtering, which makes text input impossible. The filter context and main context also are supposed to use different keyboard modes, and this change breaks that too.

}
queue->modifiers_keycode.emplace_back();
queue->modifiers_keycode.emplace_back( std::set<keymod_t>( { keymod_t::shift } ) );
Copy link
Contributor

@Qrox Qrox Mar 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was here for a reason and you shouldn't simply remove it. It makes the queue generate hotkeys modified with the shift key in place of capital letters in character mode.

@@ -1896,26 +1896,19 @@ const hotkey_queue &hotkey_queue::alphabets()
return *queue;
}

const hotkey_queue &hotkey_queue::alpha_digits()
const hotkey_queue &hotkey_queue::create_from_available_hotkeys( input_context &ctxt )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always return the queue created for the first input context this function is called with, because queue is static.

@@ -348,7 +349,7 @@ void uilist::filterlist()

void uilist::inputfilter()
{
input_context ctxt( input_category, keyboard_mode::keychar );
ctxt.set_category( input_category );
Copy link
Contributor

@Qrox Qrox Mar 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make the filter context have actions registered in the main context, which may cause incorrect behavior,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) Controls / Input Keyboard, mouse, keybindings, input UI, etc. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Key conflicts with Map Note List
4 participants