Skip to content

Commit 2cb379b

Browse files
authored
Merge pull request #781 from rswinkle/support_numpad_enter2
Add NumPad Enter to other backends
2 parents a15e34f + f3d9f45 commit 2cb379b

File tree

23 files changed

+76
-61
lines changed

23 files changed

+76
-61
lines changed

demo/allegro5/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int main(void)
120120
al_register_event_source(event_queue, al_get_mouse_event_source());
121121
al_register_event_source(event_queue, al_get_keyboard_event_source());
122122

123-
font = nk_allegro5_font_create_from_file("../../../extra_font/Roboto-Regular.ttf", 12, 0);
123+
font = nk_allegro5_font_create_from_file("../../extra_font/Roboto-Regular.ttf", 12, 0);
124124

125125
ctx = nk_allegro5_init(font, display, WINDOW_WIDTH, WINDOW_HEIGHT);
126126

demo/allegro5/nuklear_allegro5.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ nk_allegro5_handle_event(ALLEGRO_EVENT *ev)
417417

418418
if (kc == ALLEGRO_KEY_LSHIFT || kc == ALLEGRO_KEY_RSHIFT) nk_input_key(ctx, NK_KEY_SHIFT, down);
419419
else if (kc == ALLEGRO_KEY_DELETE) nk_input_key(ctx, NK_KEY_DEL, down);
420-
else if (kc == ALLEGRO_KEY_ENTER) nk_input_key(ctx, NK_KEY_ENTER, down);
420+
else if (kc == ALLEGRO_KEY_ENTER || kc == ALLEGRO_KEY_PAD_ENTER) nk_input_key(ctx, NK_KEY_ENTER, down);
421421
else if (kc == ALLEGRO_KEY_TAB) nk_input_key(ctx, NK_KEY_TAB, down);
422422
else if (kc == ALLEGRO_KEY_LEFT) nk_input_key(ctx, NK_KEY_LEFT, down);
423423
else if (kc == ALLEGRO_KEY_RIGHT) nk_input_key(ctx, NK_KEY_RIGHT, down);

demo/d3d11/nuklear_d3d11.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
232232
return 1;
233233

234234
case VK_RETURN:
235+
case VK_SEPARATOR:
235236
nk_input_key(&d3d11.ctx, NK_KEY_ENTER, down);
236237
return 1;
237238

demo/d3d12/nuklear_d3d12.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ nk_d3d12_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
364364
return 1;
365365

366366
case VK_RETURN:
367+
case VK_SEPARATOR:
367368
nk_input_key(&d3d12.ctx, NK_KEY_ENTER, down);
368369
return 1;
369370

demo/d3d9/nuklear_d3d9.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ nk_d3d9_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
292292
return 1;
293293

294294
case VK_RETURN:
295+
case VK_SEPARATOR:
295296
nk_input_key(&d3d9.ctx, NK_KEY_ENTER, down);
296297
return 1;
297298

demo/gdi/nuklear_gdi.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
7676
image->region[1] = 0;
7777
image->region[2] = width;
7878
image->region[3] = height;
79-
79+
8080
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
8181
bi.bmiHeader.biWidth = width;
8282
bi.bmiHeader.biHeight = height;
8383
bi.bmiHeader.biPlanes = 1;
8484
bi.bmiHeader.biBitCount = 24;
8585
bi.bmiHeader.biCompression = BI_RGB;
8686
bi.bmiHeader.biSizeImage = row * height;
87-
87+
8888
hbm = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**)&lpBuf, NULL, 0);
89-
89+
9090
pb = lpBuf + row * height;
9191
for (v = 0; v < height; v++)
9292
{
@@ -98,7 +98,7 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
9898
pb[i + 2] = src[2];
9999
src += 3;
100100
}
101-
}
101+
}
102102
SetDIBits(NULL, hbm, 0, height, lpBuf, &bi, DIB_RGB_COLORS);
103103
image->handle.ptr = hbm;
104104
}
@@ -122,10 +122,10 @@ nk_gdi_draw_image(short x, short y, unsigned short w, unsigned short h,
122122
HBITMAP hbm = (HBITMAP)img.handle.ptr;
123123
HDC hDCBits;
124124
BITMAP bitmap;
125-
125+
126126
if (!gdi.memory_dc || !hbm)
127127
return;
128-
128+
129129
hDCBits = CreateCompatibleDC(gdi.memory_dc);
130130
GetObject(hbm, sizeof(BITMAP), (LPSTR)&bitmap);
131131
SelectObject(hDCBits, hbm);
@@ -192,7 +192,7 @@ nk_gdi_stroke_rect(HDC dc, short x, short y, unsigned short w,
192192
}
193193
SelectObject(dc, br);
194194

195-
if (pen) {
195+
if (pen) {
196196
SelectObject(dc, GetStockObject(DC_PEN));
197197
DeleteObject(pen);
198198
}
@@ -470,7 +470,7 @@ nk_gdi_stroke_circle(HDC dc, short x, short y, unsigned short w,
470470
pen = CreatePen(PS_SOLID, line_thickness, color);
471471
SelectObject(dc, pen);
472472
}
473-
473+
474474
HGDIOBJ br = SelectObject(dc, GetStockObject(NULL_BRUSH));
475475
SetDCBrushColor(dc, OPAQUE);
476476
Ellipse(dc, x, y, x + w, y + h);
@@ -524,7 +524,7 @@ nk_gdi_draw_text(HDC dc, short x, short y, unsigned short w, unsigned short h,
524524
wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
525525
wstr = (WCHAR*)_alloca(wsize * sizeof(wchar_t));
526526
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
527-
527+
528528
SetBkMode(dc, TRANSPARENT); /* Transparent Text Background */
529529
SetBkColor(dc, convert_color(cbg));
530530
SetTextColor(dc, convert_color(cfg));
@@ -599,14 +599,14 @@ nk_gdi_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
599599
(void)usr;
600600
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
601601
{
602-
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
602+
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
603603
if (mem)
604604
{
605605
SIZE_T size = GlobalSize(mem) - 1;
606606
if (size)
607607
{
608608
LPCWSTR wstr = (LPCWSTR)GlobalLock(mem);
609-
if (wstr)
609+
if (wstr)
610610
{
611611
int utf8size = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)(size / sizeof(wchar_t)), NULL, 0, NULL, NULL);
612612
if (utf8size)
@@ -619,7 +619,7 @@ nk_gdi_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
619619
free(utf8);
620620
}
621621
}
622-
GlobalUnlock(mem);
622+
GlobalUnlock(mem);
623623
}
624624
}
625625
}
@@ -643,9 +643,9 @@ nk_gdi_clipboard_copy(nk_handle usr, const char *text, int len)
643643
{
644644
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
645645
wstr[wsize] = 0;
646-
GlobalUnlock(mem);
646+
GlobalUnlock(mem);
647647

648-
SetClipboardData(CF_UNICODETEXT, mem);
648+
SetClipboardData(CF_UNICODETEXT, mem);
649649
}
650650
}
651651
}
@@ -734,6 +734,7 @@ nk_gdi_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
734734
return 1;
735735

736736
case VK_RETURN:
737+
case VK_SEPARATOR:
737738
nk_input_key(&gdi.ctx, NK_KEY_ENTER, down);
738739
return 1;
739740

@@ -776,7 +777,7 @@ nk_gdi_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
776777
case VK_PRIOR:
777778
nk_input_key(&gdi.ctx, NK_KEY_SCROLL_UP, down);
778779
return 1;
779-
780+
780781
case 'A':
781782
if (ctrl) {
782783
nk_input_key(&gdi.ctx, NK_KEY_TEXT_SELECT_ALL, down);

demo/gdi_native_nuklear/nuklear_gdi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* Nuklear - 1.32.0 - public domain
33
* no warrenty implied; use at your own risk.
44
* authored from 2015-2016 by Micha Mettke
5-
*
5+
*
66
* Modified GDI backend 2022
77
* Now based on a context that is required for each API function call.
88
* Removes the global state --> you can have multiple windows :-)
9-
*
9+
*
1010
*/
1111
/*
1212
* ==============================================================
@@ -698,6 +698,7 @@ nk_gdi_handle_event(nk_gdi_ctx gdi, HWND wnd, UINT msg, WPARAM wparam, LPARAM lp
698698
return 1;
699699

700700
case VK_RETURN:
701+
case VK_SEPARATOR:
701702
nk_input_key(&gdi->ctx, NK_KEY_ENTER, down);
702703
return 1;
703704

demo/gdip/nuklear_gdip.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ typedef enum {
9292
StringFormatFlagsMeasureTrailingSpaces = 0x00000800,
9393
StringFormatFlagsNoWrap = 0x00001000,
9494
StringFormatFlagsLineLimit = 0x00002000,
95-
StringFormatFlagsNoClip = 0x00004000
95+
StringFormatFlagsNoClip = 0x00004000
9696
} StringFormatFlags;
9797

9898
typedef enum
@@ -272,25 +272,25 @@ GdipSetStringFormatFlags(GpStringFormat *format, INT flags);
272272
GpStatus WINGDIPAPI
273273
GdipDeleteStringFormat(GpStringFormat *format);
274274

275-
GpStatus WINGDIPAPI
276-
GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
275+
GpStatus WINGDIPAPI
276+
GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
277277
GDIPCONST void* memory, INT length);
278278

279-
GpStatus WINGDIPAPI
280-
GdipPrivateAddFontFile(GpFontCollection* fontCollection,
279+
GpStatus WINGDIPAPI
280+
GdipPrivateAddFontFile(GpFontCollection* fontCollection,
281281
GDIPCONST WCHAR* filename);
282282

283-
GpStatus WINGDIPAPI
283+
GpStatus WINGDIPAPI
284284
GdipNewPrivateFontCollection(GpFontCollection** fontCollection);
285285

286-
GpStatus WINGDIPAPI
286+
GpStatus WINGDIPAPI
287287
GdipDeletePrivateFontCollection(GpFontCollection** fontCollection);
288288

289-
GpStatus WINGDIPAPI
290-
GdipGetFontCollectionFamilyList(GpFontCollection* fontCollection,
289+
GpStatus WINGDIPAPI
290+
GdipGetFontCollectionFamilyList(GpFontCollection* fontCollection,
291291
INT numSought, GpFontFamily* gpfamilies[], INT* numFound);
292292

293-
GpStatus WINGDIPAPI
293+
GpStatus WINGDIPAPI
294294
GdipGetFontCollectionFamilyCount(GpFontCollection* fontCollection, INT* numFound);
295295

296296

@@ -374,8 +374,8 @@ GdipGraphicsClear(GpGraphics *graphics, ARGB color);
374374
GpStatus WINGDIPAPI
375375
GdipDrawImageI(GpGraphics *graphics, GpImage *image, INT x, INT y);
376376

377-
GpStatus WINGDIPAPI
378-
GdipDrawImageRectI(GpGraphics *graphics, GpImage *image, INT x, INT y,
377+
GpStatus WINGDIPAPI
378+
GdipDrawImageRectI(GpGraphics *graphics, GpImage *image, INT x, INT y,
379379
INT width, INT height);
380380

381381
GpStatus WINGDIPAPI
@@ -673,7 +673,7 @@ nk_gdip_load_image_from_memory(const void *membuf, nk_uint membufSize)
673673
IStream *stream = SHCreateMemStream((const BYTE*)membuf, membufSize);
674674
if (!stream)
675675
return nk_image_id(0);
676-
676+
677677
status = GdipLoadImageFromStream(stream, &image);
678678
stream->lpVtbl->Release(stream);
679679

@@ -709,7 +709,7 @@ nk_gdipfont_create(const char *name, int size)
709709
return font;
710710
}
711711

712-
GpFontCollection*
712+
GpFontCollection*
713713
nk_gdip_getCurFontCollection(){
714714
return gdip.fontCollection[gdip.curFontCollection];
715715
}
@@ -744,7 +744,7 @@ nk_gdipfont_create_from_file(const WCHAR* filename, int size)
744744
{
745745
if( !nk_gdip_getCurFontCollection() )
746746
if( GdipNewPrivateFontCollection(&gdip.fontCollection[gdip.curFontCollection]) ) return NULL;
747-
if( GdipPrivateAddFontFile(nk_gdip_getCurFontCollection(), filename) ) return NULL;
747+
if( GdipPrivateAddFontFile(nk_gdip_getCurFontCollection(), filename) ) return NULL;
748748
return nk_gdipfont_create_from_collection(size);
749749
}
750750

@@ -849,7 +849,7 @@ nk_gdip_init(HWND hwnd, unsigned int width, unsigned int height)
849849
GdipCreatePen1(0, 1.0f, UnitPixel, &gdip.pen);
850850
GdipCreateSolidFill(0, &gdip.brush);
851851
GdipStringFormatGetGenericTypographic(&gdip.format);
852-
GdipSetStringFormatFlags(gdip.format, StringFormatFlagsNoFitBlackBox |
852+
GdipSetStringFormatFlags(gdip.format, StringFormatFlagsNoFitBlackBox |
853853
StringFormatFlagsMeasureTrailingSpaces | StringFormatFlagsNoWrap |
854854
StringFormatFlagsNoClip);
855855

@@ -924,6 +924,7 @@ nk_gdip_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
924924
return 1;
925925

926926
case VK_RETURN:
927+
case VK_SEPARATOR:
927928
nk_input_key(&gdip.ctx, NK_KEY_ENTER, down);
928929
return 1;
929930

demo/glfw_opengl2/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
/* #define INCLUDE_CALCULATOR */
4343
/* #define INCLUDE_CANVAS */
4444
/* #define INCLUDE_FILE_BROWSER */
45-
/* #define INCLUDE_OVERVIEW */
45+
#define INCLUDE_OVERVIEW
4646
/* #define INCLUDE_CONFIGURATOR */
4747
/* #define INCLUDE_NODE_EDITOR */
4848

demo/glfw_opengl2/nuklear_glfw_gl2.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ nk_glfw3_new_frame(void)
327327
glfwSetInputMode(glfw.win, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
328328

329329
nk_input_key(ctx, NK_KEY_DEL, glfwGetKey(win, GLFW_KEY_DELETE) == GLFW_PRESS);
330-
nk_input_key(ctx, NK_KEY_ENTER, glfwGetKey(win, GLFW_KEY_ENTER) == GLFW_PRESS);
330+
nk_input_key(ctx, NK_KEY_ENTER, glfwGetKey(win, GLFW_KEY_ENTER) == GLFW_PRESS ||
331+
glfwGetKey(win, GLFW_KEY_KP_ENTER) == GLFW_PRESS);
332+
331333
nk_input_key(ctx, NK_KEY_TAB, glfwGetKey(win, GLFW_KEY_TAB) == GLFW_PRESS);
332334
nk_input_key(ctx, NK_KEY_BACKSPACE, glfwGetKey(win, GLFW_KEY_BACKSPACE) == GLFW_PRESS);
333335
nk_input_key(ctx, NK_KEY_UP, glfwGetKey(win, GLFW_KEY_UP) == GLFW_PRESS);

0 commit comments

Comments
 (0)