Merged in mattbrejza/ugfx/widgets_mouse_fix (pull request #24)
Enhancing toggle support for widgets
This commit is contained in:
commit
e1c7003fa3
1 changed files with 26 additions and 2 deletions
|
@ -365,8 +365,9 @@ void _gwidgetInit(void)
|
||||||
{
|
{
|
||||||
geventListenerInit(&gl);
|
geventListenerInit(&gl);
|
||||||
geventRegisterCallback(&gl, gwidgetEvent, 0);
|
geventRegisterCallback(&gl, gwidgetEvent, 0);
|
||||||
|
#if GINPUT_NEED_MOUSE
|
||||||
geventAttachSource(&gl, ginputGetMouse(GMOUSE_ALL_INSTANCES), GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES);
|
geventAttachSource(&gl, ginputGetMouse(GMOUSE_ALL_INSTANCES), GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES);
|
||||||
|
#endif
|
||||||
#if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD
|
#if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD
|
||||||
geventAttachSource(&gl, ginputGetKeyboard(GKEYBOARD_ALL_INSTANCES), GLISTEN_KEYUP);
|
geventAttachSource(&gl, ginputGetKeyboard(GKEYBOARD_ALL_INSTANCES), GLISTEN_KEYUP);
|
||||||
#endif
|
#endif
|
||||||
|
@ -616,6 +617,29 @@ bool_t gwinAttachListener(GListener *pl) {
|
||||||
wvmt->ToggleAssign(gw, role, instance);
|
wvmt->ToggleAssign(gw, role, instance);
|
||||||
return geventAttachSource(&gl, gsh, GLISTEN_TOGGLE_ON|GLISTEN_TOGGLE_OFF);
|
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
|
#endif
|
||||||
|
|
||||||
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
|
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
|
||||||
|
|
Loading…
Add table
Reference in a new issue