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

Key repeat for nk_keys #639

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

PROP65
Copy link

@PROP65 PROP65 commented May 9, 2024

Adds key repeat for nk_keys (Arrows, Home, End, Backspace, Delete, etc).

Requires nk_context.delta_time_seconds to be set before nk_input_end call.

The default delay and interval can be changed, as well as updated at runtime.

/* send 20 inputs per second after a key has been held for 1/3 of a second */
#define NK_INPUT_REPEATER_DELAY 0.33f
#define NK_INPUT_REPEATER_INTERVAL 0.05f
#include "nuklear.h"

...

struct nk_context ctx;
nk_init_default(&ctx, 0);
/* update at runtime, 10 inputs per second after .4 seconds */
ctx.input.keyboard.repeater_delay    = 0.40f;
ctx.input.keyboard.repeater_interval = 0.10f;

Tested and working with the following render backends.

  • glfw_opengl3
  • glfw_vulkan
  • sdl_opengl3
  • x11_opengl2
  • x11_opengl3

@RobLoach
Copy link
Contributor

Nice work! Looking good... Adding delta time to the renders will help too #628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants