开发者

Enable or disable the next button based on a live text control value in Wix? [duplicate]

This question already has answers here: WIX UI - Creating a "passwords don't match" label (4 answers) Closed 6 years ago.

I created a custom dialog page in wix and it has a text box. I want to disable the next button of the installer if the text box is empty end enable it if the user has typed a value. The following code works partially. It does not disable the next button but it does not navigate to the next page unless you fill the value. The problem I have is that the status of the next button is not updated while you are typing a value in the edit text box. If I remove the value from the edit text box and then click back to the previous screen and then next, the next button is disabled.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
 <Fragment>
    <UI>
      <Dialog Id="MyCustomDialog" Width="370" Height="270" Title="Custom Dialog Options">
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
          <Condition Action="disable">USERNAME1 = ""</Condition>
          <Condition Action="enable">NOT(USERNAME1 = "")</Condition>
          <Publish Event="NewDialog" Value="VerifyReadyDlg">NOT(USERNAME1 = "")</Publish>
        </Control>
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back">
          <Publish Event="NewDialog" Value="CustomizeDlg">1</Publish>
        </Control>
        <Control Id="Cancel" Type="PushButton" X="304" Y="开发者_如何学JAVA243" Width="56" Height="17" Cancel="yes" Text="Cancel">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

        <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please type the value" />

        <Control Id="UserNameText" Type="Text" X="20" Y="60" Width="290" Height="13"  NoPrefix="yes" Text="Please type the username" />
        <Control Id="UserNameEdit" Type="Edit" X="20" Y="72" Width="290" Height="18" Multiline="no" Property="USERNAME1"/>

      </Dialog>
    </UI>
 </Fragment>
</Wix>


Disabling and enabling the "Next" button is nearly impossible in WIX. The answer from @Wjdavis5 disabled the "Next" button for me but the button will only enable if the user clicks in another text box. Which is confusing.

The following code is based on this answer. It shows a single text entry box, when the user clicks "Next" it either shows an error dialog, or progresses to the install screen.

<Dialog Id="UserRegistrationDialog" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
    <Control Id="UserIdEdit" Type="Edit" X="45" Y="85" Width="220" Height="18" Property="UserID" Text="{80}" />

    <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next" >
      <Publish Event="NewDialog" Value="VerifyReadyDlg">2</Publish>
      <Publish Event="SpawnDialog" Value="UserIdError"><![CDATA[UserID = ""]]></Publish>
    </Control>
</Dialog>

<Dialog Id="UserIdError" Width="260" Height="85" NoMinimize="no" Title="[ProductName]"> 
    <Control Id="UserIdErrorDesc" Type="Text" Width="194" Height="30" X="48" Y="15" Text="Please enter a User ID." />
    <Control Id="UserIdErrorOk" Type="PushButton" X="97" Y="57" Width="56" Height="17" Text="Ok">
      <Publish  Event="EndDialog" Value="Return">1</Publish>
    </Control>
</Dialog>


Here is how I did it.

<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
      <Condition Action="enable"><![CDATA[InDBCONNECTION_STRING_VALID = "1"]]></Condition>
      <Condition Action="disable"><![CDATA[InDBCONNECTION_STRING_VALID = "0"]]></Condition>
</Control>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜