Skip to content

Scroll fights me in a menu full of rows and label/button pairs. #129

@StrikerTheHedgefox

Description

@StrikerTheHedgefox

Video: https://shadowmavericks.com/files/ShareX/tfury_2025-11-02_15-13-42.mp4

Every time I try to scroll my binds menu up and down, the scrollbar and mouse all fight me, preventing proper scrolling. Can only scroll through it with the keyboard.

void UIFunc_OnConfigureBinds(nk_console* button, void* user_data)
{
	TFURY_UNREFERENCED_PARAMETER(button);

	nk_console_free_children(configureBinds);
	
	// Gather all input types, and form rows in the configure binds menu.
	for (int action = 1; action < INPUT_MAX_INPUTS; action++)
	{
		nk_console* row = nk_console_row_begin(configureBinds);

		nk_console_label(row, gameInputs[action].friendlyName);

		free(inputMenuList[action].keys);
		inputMenuList[action].keys = calloc(1, sizeof(char));

		uint8_t first = 1;
		for (int key = SDL_SCANCODE_A; key < SDL_NUM_SCANCODES; key++)
		{			
			if (keyBinds[key] == action)
			{
				if (!first)
					inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, ", ");

				inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, SDL_GetKeyName(SDL_GetKeyFromScancode(key)));
				
				first = 0;
			}
		}

		for (int joyButton = 0; joyButton < MAX_BUTTONS; joyButton++)
		{
			if (joyBinds[joyButton] == action)
			{
				if (!first)
					inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, ", ");

				char buffer[80];
				snprintf(buffer, sizeof(buffer), "BTN %d", joyButton);
				inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, buffer);

				first = 0;
			}

			if (joyModBinds[joyButton] == action)
			{
				if (!first)
					inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, ", ");

				char buffer[80];
				snprintf(buffer, sizeof(buffer), "Mod. BTN %d", joyButton);
				inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, buffer);

				first = 0;
			}
		}

		for (int hatDir = 0; hatDir < HAT_NUMDIRECTIONS; hatDir++)
		{
			if (hatActions[hatDir] == action)
			{
				if (!first)
					inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, ", ");

				inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, hatNames[hatDir]);

				first = 0;
			}

			if (hatModifierActions[hatDir] == action)
			{
				if (!first)
					inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, ", ");

				char buffer[80];
				snprintf(buffer, sizeof(buffer), "Mod. %s", hatNames[hatDir]);
				inputMenuList[action].keys = appendStrRealloc(inputMenuList[action].keys, buffer);

				first = 0;
			}
		}

		// Slap down a button that'll send us where we want to go. (Bind key menu)
		inputMenuList[action].menuItem = nk_console_button(row, inputMenuList[action].keys);
		nk_console_add_event_handler(inputMenuList[action].menuItem, NK_CONSOLE_EVENT_CLICKED, UIFunc_OnBindKey, (void*)action, NULL);

		nk_console_row_end(row);
	}

	if((int)user_data == 0)
		nk_console_set_active_parent(configureBinds);
	else
	{
		// HACK. Partial reimplementation of nk_console_set_active_parent without scroll set to avoid an assert.
		nk_console* top = nk_console_get_top(configureBinds);
		if (top == NULL)
			return;

		nk_console_top_data* data = (nk_console_top_data*)top->data;
		data->active_parent = configureBinds;
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions