Passing keyboard events to widgets (not finished yet)
This commit is contained in:
parent
cf06739b4e
commit
16d213d4ed
13 changed files with 81 additions and 0 deletions
|
@ -95,6 +95,11 @@ static const gwidgetVMT buttonVMT = {
|
|||
0, // Process mouse move events (NOT USED)
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
1, // 1 toggle role
|
||||
|
|
|
@ -91,6 +91,11 @@ static const gwidgetVMT checkboxVMT = {
|
|||
0, // Process mouse move events (NOT USED)
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
1, // 1 toggle role
|
||||
|
|
|
@ -96,6 +96,11 @@ typedef struct gwinVMT {
|
|||
void (*MouseMove) (GWidgetObject *gw, coord_t x, coord_t y); // @< Process mouse move events (optional)
|
||||
};
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
struct {
|
||||
void (*KeyboardEvent) (GWidgetObject *gw, GEventKeyboard *pke); // @< Process keyboard events (optional)
|
||||
};
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
struct {
|
||||
uint16_t toggleroles; // @< The roles supported for toggles (0->toggleroles-1)
|
||||
|
|
|
@ -110,6 +110,11 @@ static const gcontainerVMT containerVMT = {
|
|||
0, 0, 0, // No mouse
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
0, 0, 0, 0, 0, // No toggles
|
||||
|
|
|
@ -178,6 +178,11 @@ static const gcontainerVMT frameVMT = {
|
|||
0, // Process mouse move events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
0, // 1 toggle role
|
||||
|
|
|
@ -313,6 +313,11 @@ static const gwidgetVMT keyboardVMT = {
|
|||
KeyMouseMove, // Process mouse move events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
0, // No toggle roles
|
||||
|
|
|
@ -58,6 +58,11 @@ static const gwidgetVMT labelVMT = {
|
|||
0, // Process mouse move events (NOT USED)
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard key down events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
0, // No toggle role
|
||||
|
|
|
@ -279,6 +279,11 @@ static const gwidgetVMT listVMT = {
|
|||
ListMouseMove,
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
2, // two toggle roles
|
||||
|
|
|
@ -51,6 +51,11 @@ static const gwidgetVMT progressbarVMT = {
|
|||
0, // Process mouse move events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
0, // 1 toggle role
|
||||
|
|
|
@ -92,6 +92,11 @@ static const gwidgetVMT radioVMT = {
|
|||
0, // Process mouse move events (NOT USED)
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
1, // 1 toggle role
|
||||
|
|
|
@ -250,6 +250,11 @@ static const gwidgetVMT sliderVMT = {
|
|||
SliderMouseMove, // Process mouse move events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
2, // 1 toggle role
|
||||
|
|
|
@ -77,6 +77,11 @@ static const gcontainerVMT tabpageVMT = {
|
|||
0, // Process mouse move events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
0 // Process keyboard events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
0, // 1 toggle role
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue