button - Wix UI 如何将焦点从一个按钮控件更改为另一个?

标签 button user-interface wix focus

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

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

有趣的是,对话框的默认控件确实已更改,但选项卡式控件仍然保留打开浏览对话框 CustomAction 的 PushButton。这种情况会导致不稳定的行为,即当按下 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'.

最佳答案

我不知道在 MSI UI 中控制焦点的方法。您可以尝试的一件事是将“下一步”按钮保留为默认但禁用。这可能使 Enter 键导致按下焦点按钮(更改按钮)。也有一个很好的机会行不通。 MSI UI 在很多方面都相当有限。

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

关于button - Wix UI 如何将焦点从一个按钮控件更改为另一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16818296/

相关文章:

flutter - 如何在 Flutter 中左对齐 OutlineButton 图标

c# - 启用应用按钮的事件

c++ - Qt 中的可伸缩图形用户界面

JavaFX 如何在不损失质量的情况下使用和缩放图像/图标?

WIX - 如何有选择地卸载 <Bundle>

javascript - 将特定 JS 转换为通用 jQuery 脚本(示例)

android - 如何实现动态创建按钮的监听器?

java - 我可以分层 JavaFX 控件吗?

c# - 如何通过调用带字符串参数的 WiX 自定义操作的 Installshield 创建自定义操作?

wix - 为什么 Windows Installer 在删除过程中不使用 .msi 文件中的 UI?