nsis中文本框失去焦点时如何调用事件

How to invoke an event when a text box loses focus in nsis

我想在 nsis 安装程序中当文本框失去焦点时调用一个事件,以便在调用该事件时我可以执行一个功能。

nsDialogs 不支持此事件,您通常会使用 OnChange 事件来更新 UI 的其他部分。

如果你绝对必须这样做,你可以使用计时器:

!include LogicLib.nsh
!include nsDialogs.nsh
Page Custom MyPageCreate
Page InstFiles

Var MyEdit
Var LastFocus

Function MyEditLostFocus
System::Call KERNEL32::GetTickCount()i.r0
SendMessage  ${WM_SETTEXT} 0 "STR:MyEditLostFocus, tick=[=10=]"
FunctionEnd

Function DetectFocusTimerHack
System::Call 'USER32::GetFocus()i.r0'
${If} [=10=] <> $MyEdit
${AndIf} $LastFocus = $MyEdit
    Push [=10=]
    Call MyEditLostFocus
    Pop [=10=]
${EndIf}
StrCpy $LastFocus [=10=]
FunctionEnd

Function MyPageCreate
nsDialogs::Create 1018
Pop [=10=]

${NSD_CreateText} 0 30u 100% 20u "Hello"
Pop $MyEdit

${NSD_CreateText} 0 60u 100% 20u "World"
Pop 

${NSD_CreateTimer} DetectFocusTimerHack 333
nsDialogs::Show
FunctionEnd