Wix UI如何将焦点从一个PushButton控件更改为另一个?

时间:2013-05-29 15:40:38

标签: button user-interface wix focus

我有一个对话框,可让用户借助自定义操作选择网络共享。除非已设置此位置,否则我不希望用户能够继续安装。为了达到这个目的,我禁用了将用户带到下一个对话框的PushButton控件。我的CustomAction设置了一个属性,该属性在该PushButton控件的Condition元素中检查。

这一切都运作良好。困扰我的是我希望用户能够尽可能轻松地浏览对话框。这就是我制作PushButton控件的原因,它将用户带到浏览对话框CustomAction,即对话框的默认控件。这也基于CustomAction设置的属性条件。设置属性后,将启用用户到下一个对话框的PushButton并将其设置为默认控件。正如您在屏幕截图中看到的那样,这确实有效。

有趣的是,对话框的默认控件确实已经更改,但选项卡式控件仍然是PushButton,它会打开浏览对话框CustomAction。这种情况导致不稳定的行为,当按下Return键时,浏览对话框再次打开,尽管已经设置了属性,即已经选择了文件夹路径。 First screen of a sample installer showing the disabled next button. The default and focused Control is the Change PushButton control which brings up a dialog created by a CustomAction. Second screen of a sample installer showing the same Dialog after the user has chosen a folder, i.e. the VIEWDIR property has been set (see code)

有什么方法可以纠正这种行为吗?我希望焦点根据属性的状态从一个控件转移到另一个控件。我该怎么做?

另外:TabSkip和Default属性如何结合在一起?

以下是对话代码:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <CustomActionRef Id="OpenFolderBrowser"/>
    <UI>
      <Dialog Id="RemoteViewDirectory" X="0" Y="0" Width="374" Height="266" Title="!(loc.GlobalDialogTitle)" NoMinimize="yes">
        <Control Id="TopBanner" Type="Bitmap" X="0" Y="0" Width="374" Height="44" Text="TopBanner" TabSkip="yes" Disabled="yes" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="373" Height="0" TabSkip="yes" Disabled="yes" />
        <Control Id="DlgSubTitle" Type="Text" X="13" Y="6" Width="292" Height="25" TabSkip="yes" Transparent="yes">
          <Text><![CDATA[{&MSSansBold8}!(loc.VwDrctryDlgSubtitle)]]></Text>
        </Control>
        <Control Id="DlgDesc" Type="Text" X="21" Y="23" Width="292" Height="25" TabSkip="yes" Transparent="yes">
          <Text><![CDATA[{&Tahoma8}!(loc.VwDrctryDlgDesc)]]></Text>
        </Control>
        <Control Id="GroupBox" Type="GroupBox" X="15" Y="174" Width="344" Height="41" TabSkip="yes">
          <Text><![CDATA[!(loc.VwDrctryDlgSubtitle)]]></Text>
        </Control>
        <Control Id="ChangeRemoteFolder" Type="PushButton" X="285" Y="189" Width="66" Height="17" TabSkip="no">
          <Text><![CDATA[!(loc.BtnTextChange)]]></Text>
          <Condition Action="default"><![CDATA[NOT VIEWDIR]]></Condition>
          <Publish Event="DoAction" Value="OpenFolderBrowser" Order="1">1</Publish>
          <Publish Property="VIEWDIR" Value="[REMOTEDIR]" Order="2"><![CDATA[REMOTEDIR]]></Publish>
          <Publish Property="REMOTEDIR" Order="3">1</Publish>
        </Control>
        <Control Id="ChgdLocation" Type="Text" X="57" Y="192" Width="220" Height="20" Property="VIEWDIR" Text="[VIEWDIR]" TabSkip="yes">
          <Condition Action="show"><![CDATA[VIEWDIR]]></Condition>
          <Condition Action="hide"><![CDATA[NOT VIEWDIR]]></Condition>
        </Control>
        <Control Id="DummyNetworkLocation" Type="Text" X="57" Y="192" Width="220" Height="20" Text="!(loc.TxtDummyViewNetworkPath)" TabSkip="yes">
          <Condition Action="show"><![CDATA[NOT VIEWDIR]]></Condition>
          <Condition Action="hide"><![CDATA[VIEWDIR]]></Condition>
        </Control>
        <Control Id="Back" Type="PushButton" X="164" Y="243" Width="66" Height="16" TabSkip="yes">
          <Text>!(loc.BtnTextBack)</Text>
          <Publish Event="NewDialog" Value="PreviousDialog">1</Publish>
        </Control>
        <Control Id="Next" Type="PushButton" X="230" Y="243" Width="66" Height="17" TabSkip="yes">
          <Text>!(loc.BtnTextNext)</Text>
          <Condition Action="enable"><![CDATA[VIEWDIR]]></Condition>
          <Condition Action="disable"><![CDATA[NOT VIEWDIR]]></Condition>
          <Condition Action="default"><![CDATA[VIEWDIR]]></Condition>
          <Publish Event="NewDialog" Value="NextDialog">1</Publish>
        </Control>
        <Control Id="Cancel" Type="PushButton" X="301" Y="243" Width="66" Height="17" TabSkip="yes" Cancel="yes">
          <Text>!(loc.BtnTextCancel)</Text>
          <Publish Event="SpawnDialog" Value="CancelSetup">1</Publish>
        </Control>
        <Control Id="DlgLine" Type="Line" X="0" Y="234" Width="373" Height="0" TabSkip="yes" Disabled="yes" />
      </Dialog>
    </UI>
  </Fragment>
</Wix>

这是Windows Installer创建的日志的输出:

Action 17:36:08: RemoteViewDirectory. Dialog created
MSI (c) (68:AC) [17:36:09:525]: Doing action: OpenFolderBrowser
Action 17:36:09: OpenFolderBrowser. 
Action start 17:36:09: OpenFolderBrowser.
MSI (c) (68:28) [17:36:09:525]: Invoking remote custom action. DLL: C:\...\Temp\MSI9B.tmp, Entrypoint: OpenFolderBrowser
MSI (c) (68!1C) [17:36:18:608]: PROPERTY CHANGE: Adding \\Win2k3iis6\cmak property. Its value is 'exists'.
MSI (c) (68!1C) [17:36:18:608]: PROPERTY CHANGE: Adding REMOTEDIR property. Its value is '\\Win2k3iis6\cmak'.
Action ended 17:36:18: OpenFolderBrowser. Return value 1.
MSI (c) (68:AC) [17:36:18:638]: PROPERTY CHANGE: Adding VIEWDIR property. Its value is '\\Win2k3iis6\cmak'.
MSI (c) (68:AC) [17:36:18:638]: PROPERTY CHANGE: Deleting REMOTEDIR property. Its current value is '\\Win2k3iis6\cmak'.

1 个答案:

答案 0 :(得分:1)

我不知道在MSI用户界面中控制焦点的方法。您可以尝试的一件事是将Next按钮保留为Default但禁用。 可能使Enter键导致按下聚焦按钮(更改按钮)。也很有可能不会起作用。 MSI UI在很多方面都相当有限。

要回答第二个问题TabSkip属性,请从Tab键顺序中删除控件。换句话说,当按Tab键在控件之间导航时,永远不应选择带TabSkip='yes'的控件。 Default属性指示在按下Enter键时应按下的按钮。