diff options
author | Andrew Hannam <andrewh@inmarket.com.au> | 2016-07-09 17:20:53 +1000 |
---|---|---|
committer | Andrew Hannam <andrewh@inmarket.com.au> | 2016-07-09 17:20:53 +1000 |
commit | e1c7003fa32c8700b155538f51276d9da3a82ae9 (patch) | |
tree | 99b513cb16c4a596a42f8b569460d60846a43b2d /src/gwin | |
parent | 13e084ae6231857cd0d472c529f34be07d93c08b (diff) | |
parent | 47e0a0372139486a8e92ca65dce2c94b6230ec9c (diff) | |
download | uGFX-e1c7003fa32c8700b155538f51276d9da3a82ae9.tar.gz uGFX-e1c7003fa32c8700b155538f51276d9da3a82ae9.tar.bz2 uGFX-e1c7003fa32c8700b155538f51276d9da3a82ae9.zip |
Merged in mattbrejza/ugfx/widgets_mouse_fix (pull request #24)
Enhancing toggle support for widgets
Diffstat (limited to 'src/gwin')
-rw-r--r-- | src/gwin/gwin_widget.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c index 2c186316..2965e7c6 100644 --- a/src/gwin/gwin_widget.c +++ b/src/gwin/gwin_widget.c @@ -365,8 +365,9 @@ void _gwidgetInit(void) { geventListenerInit(&gl); geventRegisterCallback(&gl, gwidgetEvent, 0); - geventAttachSource(&gl, ginputGetMouse(GMOUSE_ALL_INSTANCES), GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES); - + #if GINPUT_NEED_MOUSE + geventAttachSource(&gl, ginputGetMouse(GMOUSE_ALL_INSTANCES), GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES); + #endif #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD geventAttachSource(&gl, ginputGetKeyboard(GKEYBOARD_ALL_INSTANCES), GLISTEN_KEYUP); #endif @@ -616,6 +617,29 @@ bool_t gwinAttachListener(GListener *pl) { wvmt->ToggleAssign(gw, role, instance); return geventAttachSource(&gl, gsh, GLISTEN_TOGGLE_ON|GLISTEN_TOGGLE_OFF); } + + bool_t gwinDetachToggle(GHandle gh, uint16_t role) { + uint16_t oi; + + // Is this a widget + if (!(gh->flags & GWIN_FLG_WIDGET)) + return FALSE; + + // Is the role valid + if (role >= ((gwidgetVMT *)gh->vmt)->toggleroles) + return FALSE; + + oi = ((gwidgetVMT *)gh->vmt)->ToggleGet(gw, role); + + // Remove the instance + if (oi != GWIDGET_NO_INSTANCE) { + ((gwidgetVMT *)gh->vmt)->ToggleAssign(gw, role, GWIDGET_NO_INSTANCE); + if (!FindToggleUser(oi)) + geventDetachSource(&gl, ginputGetToggle(oi)); + } + return TRUE; + } + #endif #if GFX_USE_GINPUT && GINPUT_NEED_DIAL |