From b8f4ee9443188676d0a170aff91b5018923e24ac Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Thu, 7 Mar 2013 14:42:28 +0000 Subject: [PATCH] [Fix] Small fix for list selection, Don't allow focus when mouse clicked out of boundaries. --- src/toolkit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/toolkit.c b/src/toolkit.c index 12807c2..5ce8b2d 100644 --- a/src/toolkit.c +++ b/src/toolkit.c @@ -1031,8 +1031,14 @@ static void toolkit_listScroll(Widget* wgt, int direction) { // List mouse even focus. static void toolkit_listFocus(Widget* lst, double bx, double by) { (void)bx; - lst->dat.lst.selected = (lst->h - by) / (gl_defFont.h+2.); - toolkit_listScroll(lst, 0); // Check boundaries and trigger callback. + int i; + + i = (lst->h - by) / (gl_defFont.h + 2.); + if(i< lst->dat.lst.noptions) { + // Should not be out of boundaries. + lst->dat.lst.selected = i; + toolkit_listScroll(lst, 0); // Check boundaries and trigger callback. + } } char* toolkit_getList(const unsigned int wid, char* name) {