Skip to content

Commit

Permalink
Added scrollbar shortcuts to demos
Browse files Browse the repository at this point in the history
  • Loading branch information
vurtun committed Jun 16, 2016
1 parent c9f0710 commit 920374b
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 21 deletions.
12 changes: 9 additions & 3 deletions demo/allegro5/nuklear_allegro.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion demo/d3d11/nuklear_d3d11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions demo/gdi/nuklear_gdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
14 changes: 12 additions & 2 deletions demo/gdip/nuklear_gdip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
4 changes: 4 additions & 0 deletions demo/glfw_opengl2/nuklear_glfw_gl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions demo/glfw_opengl3/nuklear_glfw_gl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
12 changes: 9 additions & 3 deletions demo/sdl_opengl2/nuklear_sdl_gl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
12 changes: 9 additions & 3 deletions demo/sdl_opengl3/nuklear_sdl_gl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
12 changes: 9 additions & 3 deletions demo/x11/nuklear_xlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 9 additions & 3 deletions demo/x11_opengl2/nuklear_xlib_gl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 9 additions & 3 deletions demo/x11_opengl3/nuklear_xlib_gl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 920374b

Please sign in to comment.