简体   繁体   English

NSIS:单击“下一步” /“后​​退”按钮后,如何保持上一个对话框的输入值?

[英]NSIS : How to keep input value from previous dialog after click Next/Back button?

If I change value in textbox and click Next button, then click Back button to back to the page again, I wanna keep new value that I changed it in textbox. 如果我在文本框中更改了值并单击“下一步”按钮,然后单击“返回”按钮再次返回到页面,则我想保留在文本框中更改了的新值。 How can I do? 我能怎么做?

This is my code : 这是我的代码:

AcustomPage.nsh AcustomPage.nsh

!macro create_AcustomPage APP_NAME CUS_FULLNAME
Page custom create_AcustomPage leave_AcustomPage
Function create_AcustomPage
        Push $0
        StrCpy $AcustomPage.FirstOpened 0
        nsDialogs::Create 1018
        Pop $AcustomPage
        GetDlgItem $AcustomPage.Button.Next $HWNDPARENT 1
        System::Call user32::GetWindowText(i$AcustomPage.Button.Next,t.s,i${NSIS_MAX_STRLEN})
        nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0u 0u 100% 20u "${AcustomPage_TITLE}"
        Pop $AcustomPage.Text
        ${NSD_CreateGroupBox} 0u 20u 100% 78% "AcustomPage Setting"
        Pop $AcustomPage.SettingBox

        ${NSD_CreateLabel} 10u 50u 20u 11u "URL:"
        Pop $AcustomPage.FULLNAME.Label
        ${NSD_CreateText} 60u 50u 60% 11u ""
        Pop $0
        ${NSD_OnChange} $0 Update_AcustomPage_Next_Button
        ${If} ${CUS_FULLNAME} != ""
            ${NSD_SetText} $0 ${CUS_FULLNAME}
        ${EndIf}

        Call Update_AcustomPage_Next_Button
        nsDialogs::Show
    FunctionEnd

    Function leave_AcustomPage
        ${NSD_GetText} $0 $CUS_FULLNAME
    FunctionEnd

    Function Update_AcustomPage_Next_Button
    Push $R5
        ${NSD_GetText} $0 $R5
        ${If} $R5 != ""
                    EnableWindow $AcustomPage.Button.Next 1
                    Return
        ${EndIf}
        ${If} $R5 == ""
            EnableWindow $AcustomPage.Button.Next 0
            Return
        ${EndIf}
    Pop $R5
    FunctionEnd
!macroend

Thanks, 谢谢,

You are on the right track by always saving the text in $CUS_FULLNAME in the leave callback but you never use $CUS_FULLNAME to set the text when creating the page, you seem to try to do something with ${CUS_FULLNAME} instead! 通过始终将文本保存在请假回调中的$ CUS_FULLNAME中,您将走上正确的轨道,但是在创建页面时从未使用$ CUS_FULLNAME设置文本,而是似乎尝试使用$ {CUS_FULLNAME}来做些事情!

It should probably look more like this: 它可能看起来应该像这样:

${NSD_CreateText} 60u 50u 60% 11u "${CUS_FULLNAME}"
Pop $0
${If} $CUS_FULLNAME != ""
  ${NSD_SetText} $0 $CUS_FULLNAME
${EndIf}
${NSD_OnChange} $0 Update_AcustomPage_Next_Button

Here is a standalone example: 这是一个独立的示例:

!include nsDialogs.nsh

var hCtlFullName
var FullName

Function mypageCreate
nsDialogs::Create 1018
Pop $0

${NSD_CreateText} 60u 30u 60% 11u "$FullName"
Pop $hCtlFullName
${NSD_OnChange} $hCtlFullName mypage_VerifyInput

call mypage_VerifyInput
nsDialogs::Show
FunctionEnd

Function mypageLeave
${NSD_GetText} $hCtlFullName $FullName
FunctionEnd

Function mypage_VerifyInput
Call mypageLeave ; Loads the text into $FullName
Push $0
GetDlgItem $0 $HWNDPARENT 1
${If} $FullName == ""
    EnableWindow $0 0
${Else}
    EnableWindow $0 1
${EndIf}
Pop $0
FunctionEnd

Page Custom mypageCreate mypageLeave
Page Components
Page InstFiles

Section
DetailPrint $FullName
SectionEnd

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击按钮时如何刷新值或显示文本框的下一个值(保存) - How to refresh value or display the next value of a textbox when button click(saved) 我在ASP.NET MVC的视图中有Button和TextBox-单击此按钮后如何将Button的值发送到TextBox? - I have Button and TextBox in View of ASP.NET MVC - how to send value of Button to TextBox after Click on this Button? 单击提交按钮后如何识别特定文本字段中值的变化 - How to identify the change of value in a particular text field after submit button click 由于某种原因,当输入字符串没有值时,它仍然显示先前的输入,但我也无法到达文本框中的下一行 - For some reason when an input string is has no value, it still shows the previous input also i can't get to the next line in the textbox NSIS:为​​什么来自文本框值的“文本”变成了数字? - NSIS : Why “Text” from text box value became numeric? 如果文本框值是AngularJs中下一个文本框的自动输入,如何隐藏错误 - how to hide the error if a textbox value is an auto input to the next textbox in AngularJs 如何通过JSP中的按钮单击来调用函数 - How to call a function from a button click in JSP 按钮单击将列表中的下一项打印到文本框 - Button click prints next item in list to a textbox 在不使用本地存储的情况下如何在移至下一页时保持文本框的值? - How to keep the textbox value while moving to the next page without using local storage? 为什么单击按钮时 $w("#input1").value 不更改? (蜡网站代码) - Why doesn't change $w("#input1").value when I click button? (Wix site code)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM