Added scrollbar shortcuts to demos
This commit is contained in:
parent
c9f07101f3
commit
920374bb44
@ -253,12 +253,18 @@ nk_allegro_handle_event(ALLEGRO_EVENT *evt)
|
||||
if (evt->keyboard.modifiers & ALLEGRO_KEYMOD_CTRL)
|
||||
nk_input_key(ctx, NK_KEY_TEXT_WORD_RIGHT, down);
|
||||
else nk_input_key(ctx, NK_KEY_RIGHT, down);
|
||||
} else if (sym == ALLEGRO_KEY_HOME)
|
||||
} else if (sym == ALLEGRO_KEY_HOME) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
else if (sym == ALLEGRO_KEY_END)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, down);
|
||||
} else if (sym == ALLEGRO_KEY_END) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
else if (sym == ALLEGRO_KEY_C)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, down);
|
||||
} else if (sym == ALLEGRO_KEY_C)
|
||||
nk_input_key(ctx, NK_KEY_COPY, down && evt->keyboard.modifiers & ALLEGRO_KEYMOD_CTRL);
|
||||
else if (sym == ALLEGRO_KEY_PGUP)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_UP, down);
|
||||
else if (sym == ALLEGRO_KEY_PGDN)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
else if (sym == ALLEGRO_KEY_V)
|
||||
nk_input_key(ctx, NK_KEY_PASTE, down && evt->keyboard.modifiers & ALLEGRO_KEYMOD_CTRL);
|
||||
else if (sym == ALLEGRO_KEY_X)
|
||||
|
@ -236,10 +236,20 @@ nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
|
||||
case VK_HOME:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_START, down);
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_START, down);
|
||||
return 1;
|
||||
|
||||
case VK_END:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_END, down);
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_END, down);
|
||||
return 1;
|
||||
|
||||
case VK_NEXT:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
return 1;
|
||||
|
||||
case VK_PRIOR:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_UP, down);
|
||||
return 1;
|
||||
|
||||
case 'C':
|
||||
@ -558,7 +568,7 @@ nk_d3d11_font_stash_end(void)
|
||||
{
|
||||
const void *image; int w, h;
|
||||
image = nk_font_atlas_bake(&d3d11.atlas, &w, &h, NK_FONT_ATLAS_RGBA32);
|
||||
|
||||
|
||||
/* upload font to texture and create texture view */
|
||||
{
|
||||
ID3D11Texture2D *font_texture;
|
||||
|
@ -559,10 +559,20 @@ nk_gdi_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
|
||||
case VK_HOME:
|
||||
nk_input_key(&gdi.ctx, NK_KEY_TEXT_START, down);
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_START, down);
|
||||
return 1;
|
||||
|
||||
case VK_END:
|
||||
nk_input_key(&gdi.ctx, NK_KEY_TEXT_END, down);
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_END, down);
|
||||
return 1;
|
||||
|
||||
case VK_NEXT:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
return 1;
|
||||
|
||||
case VK_PRIOR:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_UP, down);
|
||||
return 1;
|
||||
|
||||
case 'C':
|
||||
|
@ -792,11 +792,21 @@ nk_gdip_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
return 1;
|
||||
|
||||
case VK_HOME:
|
||||
nk_input_key(&gdip.ctx, NK_KEY_TEXT_START, down);
|
||||
nk_input_key(&gdi.ctx, NK_KEY_TEXT_START, down);
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_START, down);
|
||||
return 1;
|
||||
|
||||
case VK_END:
|
||||
nk_input_key(&gdip.ctx, NK_KEY_TEXT_END, down);
|
||||
nk_input_key(&gdi.ctx, NK_KEY_TEXT_END, down);
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_END, down);
|
||||
return 1;
|
||||
|
||||
case VK_NEXT:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
return 1;
|
||||
|
||||
case VK_PRIOR:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_UP, down);
|
||||
return 1;
|
||||
|
||||
case 'C':
|
||||
|
@ -277,6 +277,10 @@ nk_glfw3_new_frame(void)
|
||||
nk_input_key(ctx, NK_KEY_DOWN, glfwGetKey(win, GLFW_KEY_DOWN) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, glfwGetKey(win, GLFW_KEY_HOME) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, glfwGetKey(win, GLFW_KEY_END) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, glfwGetKey(win, GLFW_KEY_HOME) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, glfwGetKey(win, GLFW_KEY_END) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_DOWN, glfwGetKey(win, GLFW_KEY_PAGE_DOWN) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_UP, glfwGetKey(win, GLFW_KEY_PAGE_UP) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SHIFT, glfwGetKey(win, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS||
|
||||
glfwGetKey(win, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS);
|
||||
|
||||
|
@ -385,6 +385,10 @@ nk_glfw3_new_frame(void)
|
||||
nk_input_key(ctx, NK_KEY_DOWN, glfwGetKey(win, GLFW_KEY_DOWN) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, glfwGetKey(win, GLFW_KEY_HOME) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, glfwGetKey(win, GLFW_KEY_END) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, glfwGetKey(win, GLFW_KEY_HOME) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, glfwGetKey(win, GLFW_KEY_END) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_DOWN, glfwGetKey(win, GLFW_KEY_PAGE_DOWN) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_UP, glfwGetKey(win, GLFW_KEY_PAGE_UP) == GLFW_PRESS);
|
||||
nk_input_key(ctx, NK_KEY_SHIFT, glfwGetKey(win, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS||
|
||||
glfwGetKey(win, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS);
|
||||
|
||||
|
@ -245,11 +245,17 @@ nk_sdl_handle_event(SDL_Event *evt)
|
||||
nk_input_key(ctx, NK_KEY_TAB, down);
|
||||
else if (sym == SDLK_BACKSPACE)
|
||||
nk_input_key(ctx, NK_KEY_BACKSPACE, down);
|
||||
else if (sym == SDLK_HOME)
|
||||
else if (sym == SDLK_HOME) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
else if (sym == SDLK_END)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, down);
|
||||
} else if (sym == SDLK_END) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
else if (sym == SDLK_z)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, down);
|
||||
} else if (sym == SDLK_PAGEDOWN) {
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
} else if (sym == SDLK_PAGEUP) {
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_UP, down);
|
||||
} else if (sym == SDLK_z)
|
||||
nk_input_key(ctx, NK_KEY_TEXT_UNDO, down && state[SDL_SCANCODE_LCTRL]);
|
||||
else if (sym == SDLK_r)
|
||||
nk_input_key(ctx, NK_KEY_TEXT_REDO, down && state[SDL_SCANCODE_LCTRL]);
|
||||
|
@ -356,11 +356,17 @@ nk_sdl_handle_event(SDL_Event *evt)
|
||||
nk_input_key(ctx, NK_KEY_TAB, down);
|
||||
else if (sym == SDLK_BACKSPACE)
|
||||
nk_input_key(ctx, NK_KEY_BACKSPACE, down);
|
||||
else if (sym == SDLK_HOME)
|
||||
else if (sym == SDLK_HOME) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
else if (sym == SDLK_END)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, down);
|
||||
} else if (sym == SDLK_END) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
else if (sym == SDLK_z)
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, down);
|
||||
} else if (sym == SDLK_PAGEDOWN) {
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
} else if (sym == SDLK_PAGEUP) {
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_UP, down);
|
||||
} else if (sym == SDLK_z)
|
||||
nk_input_key(ctx, NK_KEY_TEXT_UNDO, down && state[SDL_SCANCODE_LCTRL]);
|
||||
else if (sym == SDLK_r)
|
||||
nk_input_key(ctx, NK_KEY_TEXT_REDO, down && state[SDL_SCANCODE_LCTRL]);
|
||||
|
@ -512,10 +512,16 @@ nk_xlib_handle_event(Display *dpy, int screen, Window win, XEvent *evt)
|
||||
else if (*code == XK_Up) nk_input_key(ctx, NK_KEY_UP, down);
|
||||
else if (*code == XK_Down) nk_input_key(ctx, NK_KEY_DOWN, down);
|
||||
else if (*code == XK_BackSpace) nk_input_key(ctx, NK_KEY_BACKSPACE, down);
|
||||
else if (*code == XK_Home) nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
else if (*code == XK_End) nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
else if (*code == XK_Escape) nk_input_key(ctx, NK_KEY_TEXT_RESET_MODE, down);
|
||||
else {
|
||||
else if (*code == XK_Page_Up) nk_input_key(ctx, NK_KEY_SCROLL_UP, down);
|
||||
else if (*code == XK_Page_Down) nk_input_key(ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
else if (*code == XK_Home) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, down);
|
||||
} else if (*code == XK_End) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, down);
|
||||
} else {
|
||||
if (*code == 'c' && (evt->xkey.state & ControlMask))
|
||||
nk_input_key(ctx, NK_KEY_COPY, down);
|
||||
else if (*code == 'v' && (evt->xkey.state & ControlMask))
|
||||
|
@ -227,10 +227,16 @@ nk_x11_handle_event(XEvent *evt)
|
||||
else if (*code == XK_Left) nk_input_key(ctx, NK_KEY_LEFT, down);
|
||||
else if (*code == XK_Right) nk_input_key(ctx, NK_KEY_RIGHT, down);
|
||||
else if (*code == XK_BackSpace) nk_input_key(ctx, NK_KEY_BACKSPACE, down);
|
||||
else if (*code == XK_Home) nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
else if (*code == XK_End) nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
else if (*code == XK_space && !down) nk_input_char(ctx, ' ');
|
||||
else {
|
||||
else if (*code == XK_Page_Up) nk_input_key(ctx, NK_KEY_SCROLL_UP, down);
|
||||
else if (*code == XK_Page_Down) nk_input_key(ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
else if (*code == XK_Home) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, down);
|
||||
} else if (*code == XK_End) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, down);
|
||||
} else {
|
||||
if (*code == 'c' && (evt->xkey.state & ControlMask))
|
||||
nk_input_key(ctx, NK_KEY_COPY, down);
|
||||
else if (*code == 'v' && (evt->xkey.state & ControlMask))
|
||||
|
@ -597,10 +597,16 @@ nk_x11_handle_event(XEvent *evt)
|
||||
else if (*code == XK_Left) nk_input_key(ctx, NK_KEY_LEFT, down);
|
||||
else if (*code == XK_Right) nk_input_key(ctx, NK_KEY_RIGHT, down);
|
||||
else if (*code == XK_BackSpace) nk_input_key(ctx, NK_KEY_BACKSPACE, down);
|
||||
else if (*code == XK_Home) nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
else if (*code == XK_End) nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
else if (*code == XK_space && !down) nk_input_char(ctx, ' ');
|
||||
else {
|
||||
else if (*code == XK_Page_Up) nk_input_key(ctx, NK_KEY_SCROLL_UP, down);
|
||||
else if (*code == XK_Page_Down) nk_input_key(ctx, NK_KEY_SCROLL_DOWN, down);
|
||||
else if (*code == XK_Home) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_START, down);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_START, down);
|
||||
} else if (*code == XK_End) {
|
||||
nk_input_key(ctx, NK_KEY_TEXT_END, down);
|
||||
nk_input_key(ctx, NK_KEY_SCROLL_END, down);
|
||||
} else {
|
||||
if (*code == 'c' && (evt->xkey.state & ControlMask))
|
||||
nk_input_key(ctx, NK_KEY_COPY, down);
|
||||
else if (*code == 'v' && (evt->xkey.state & ControlMask))
|
||||
|
Loading…
Reference in New Issue
Block a user