From 7ff81f69b3fb8688209eee22126c4a8b7b975bf8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 5 Jun 2015 16:13:03 -0400 Subject: [PATCH] Fixed spinbox numeric entry woes. --- redo/windows/spinbox.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/redo/windows/spinbox.c b/redo/windows/spinbox.c index a1acba11..ed6b2ee3 100644 --- a/redo/windows/spinbox.c +++ b/redo/windows/spinbox.c @@ -38,11 +38,21 @@ static intmax_t value(struct spinbox *s) static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult) { struct spinbox *s = (struct spinbox *) c; + WCHAR *wtext; if (code != EN_CHANGE) return FALSE; if (s->inhibitChanged) return FALSE; + // We want to allow typing negative numbers; the natural way to do so is to start with a -. + // However, if we just have the code below, the up-down will catch the bare - and reject it. + // Let's fix that. + // This won't handle leading spaces, but spaces aren't allowed *anyway*. + wtext = windowText(s->hwnd); + if (wcscmp(wtext, L"-") == 0) { + uiFree(wtext); + return TRUE; + } // value() does the work for us value(s); (*(s->onChanged))(uiSpinbox(s), s->onChangedData); @@ -189,8 +199,8 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) s->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE, L"edit", L"", - // TODO ES_NUMBER doesn't allow typing in a leading - - ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | ES_NUMBER | WS_TABSTOP, + // don't use ES_NUMBER; it doesn't allow typing in a leading - + ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP, hInstance, NULL, TRUE);