aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/gwin_widget.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-08-12 17:32:38 +0200
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-08-12 17:32:38 +0200
commit16d213d4ed14add60e286246ad6dc563761b9689 (patch)
treed68cca3afab7ead565fcfd652474b356b2413b63 /src/gwin/gwin_widget.c
parentcf06739b4ee44bcbfac8ae99e605a4ec4e832c8b (diff)
downloaduGFX-16d213d4ed14add60e286246ad6dc563761b9689.tar.gz
uGFX-16d213d4ed14add60e286246ad6dc563761b9689.tar.bz2
uGFX-16d213d4ed14add60e286246ad6dc563761b9689.zip
Passing keyboard events to widgets (not finished yet)
Diffstat (limited to 'src/gwin/gwin_widget.c')
-rw-r--r--src/gwin/gwin_widget.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c
index bfc5a48f..666987ac 100644
--- a/src/gwin/gwin_widget.c
+++ b/src/gwin/gwin_widget.c
@@ -88,6 +88,7 @@ static const GWidgetStyle * defaultStyle = &BlackWidgetStyle;
/* Process an event */
static void gwidgetEvent(void *param, GEvent *pe) {
#define pme ((GEventMouse *)pe)
+ #define pke ((GEventKeyboard *)pe)
#define pte ((GEventToggle *)pe)
#define pde ((GEventDial *)pe)
@@ -142,6 +143,22 @@ static void gwidgetEvent(void *param, GEvent *pe) {
break;
#endif
+ #if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD
+ case GEVENT_KEYBOARD:
+ // Cycle through all windows
+ for (gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) {
+
+ // Check whether the widget is enabled and visible
+ if ((gh->flags & (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE)) != (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE)) {
+ continue;
+ }
+
+ // Pass the information
+ wvmt->KeyboardEvent(gw, pke);
+ }
+ break;
+ #endif
+
#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
case GEVENT_TOGGLE:
// Cycle through all windows
@@ -235,6 +252,10 @@ void _gwidgetInit(void)
geventListenerInit(&gl);
geventRegisterCallback(&gl, gwidgetEvent, 0);
geventAttachSource(&gl, ginputGetMouse(GMOUSE_ALL_INSTANCES), GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES);
+
+ #if GINPUT_NEED_KEYBOARD
+ geventAttachSource(&gl, ginputGetKeyboard(GKEYBOARD_ALL_INSTANCES), 0);
+ #endif
}
void _gwidgetDeinit(void)