使用botbuilder SDK的Prompt.choice(),是否可以使用显示长选择文本的自定义工具提示? [英] Using botbuilder SDK's Prompt.choice(), is it possible to have a custom tooltip which displays long choice-text?

查看:71
本文介绍了使用botbuilder SDK的Prompt.choice(),是否可以使用显示长选择文本的自定义工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NodeJS SDK通过MSFT botframework创建机器人.我给使用builder.prompt.choice的用户选择选项.如果选项值太长而无法完全查看,是否可以将鼠标悬停在可点击的选项上?代码段如下.另外,选项值是在运行时获取的,因此我们对长度没有任何控制.

I am using NodeJS SDK for creating a bot using MSFT botframework. I am giving choice option to user using builder.prompt.choice. Is it possible to hover over the clickable options in case the option values are too long to be completely viewable? The code snippet is as follows. Also the options values are getting fetched at run time, so we do not have any control over the length.

function(session, args, next) {
  builder.Prompts.choice(session, "Please select one of the options:", ['I want to hover here.....', 'Since it is a very very long sentence', 'ccc ccc ccc dddd d  d aa a a ddd a sdd d '], {
    retryPrompt: "Invalid choice, Please pick below listed choices",
    listStyle: builder.ListStyle.button,
    maxRetries: 1
  });
},
function(session, results) {
  if (results.response) {
    //Do something
  }
}

推荐答案

使用Webchat频道时,您可以按照Microsoft GitHub项目

When using the Webchat channel, you can customize the channel implementation by following the guidelines provided on Microsoft's GitHub project here .

特别是在您的情况下,您只需要删除ActionButton上的属性即可将按钮限制为1行,如果行太长则添加....

In particular, in your case you just need to remove a properties on the ActionButton that is limiting the buttons to 1 line, adding ... if the line is too long.

您需要做的修改是删除botchat.js文件中function ActionButton的以下行(看起来您不能简单地在CSS端进行此操作):

The modification that you have to do is to remove the following line on the function ActionButton in botchat.js file (looks like you can't simply do it on CSS side):

this._element.style.whiteSpace="nowrap";

这样做,您将具有如下所示的提示选择,其中第二个选择有两行:

By doing this you will have promptChoices like the following, where the 2nd choice has 2 lines:

顺便说一句,您也可以在按钮上添加标题以像我一样用鼠标悬停时获得值;-)

By the way, you can also add a title to the buttons to get the value when hovering with the mouse like I have ;-)

这篇关于使用botbuilder SDK的Prompt.choice(),是否可以使用显示长选择文本的自定义工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆