summaryrefslogtreecommitdiff
path: root/iup/src/win/iupwin_focus.c
diff options
context:
space:
mode:
Diffstat (limited to 'iup/src/win/iupwin_focus.c')
-rwxr-xr-xiup/src/win/iupwin_focus.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/iup/src/win/iupwin_focus.c b/iup/src/win/iupwin_focus.c
index 63da02d..2328dea 100755
--- a/iup/src/win/iupwin_focus.c
+++ b/iup/src/win/iupwin_focus.c
@@ -32,7 +32,7 @@
/* Since Windows XP, the focus feedback only appears after the user press a key.
Except for the IupText where the feedback is the caret.
- Before that if you click in a control the focus feedback will be hidden.
+ Before a key is pressed if you click in a control the focus feedback will be hidden.
We manually send WM_CHANGEUISTATE because we do not use IsDialogMessage anymore,
and the focus feedback was not shown even after the used press a key.
@@ -43,19 +43,28 @@
void iupdrvSetFocus(Ihandle *ih)
{
SetFocus(ih->handle);
- SendMessage(ih->handle, WM_CHANGEUISTATE, UIS_CLEAR|UISF_HIDEFOCUS, 0);
+
+ /* See comments above */
+ SendMessage(ih->handle, WM_CHANGEUISTATE, UIS_CLEAR|UISF_HIDEFOCUS, 0); /* clear+hidefocus=showfocus */
}
void iupwinWmSetFocus(Ihandle *ih)
{
Ihandle* dialog = IupGetDialog(ih);
if (ih != dialog)
- iupAttribSetStr(dialog, "_IUPWIN_LASTFOCUS", (char*)ih); /* used by IupMenu */
+ iupAttribSetStr(dialog, "_IUPWIN_LASTFOCUS", (char*)ih); /* used by IupMenu and here. */
else
{
/* if a control inside that dialog had the focus, then reset to it when the dialog gets the focus */
Ihandle* lastfocus = (Ihandle*)iupAttribGet(dialog, "_IUPWIN_LASTFOCUS");
- if (lastfocus) IupSetFocus(lastfocus);
+ if (lastfocus)
+ {
+ /* call the callback and update current focus before changing it again */
+ iupCallGetFocusCb(ih);
+
+ IupSetFocus(lastfocus);
+ return;
+ }
}
iupCallGetFocusCb(ih);