工具提示是GUI(图形用户界面)元素,当鼠标指针悬停在GUI中的项目上并提供一些上下文信息或说明时,它通常会弹出。
我希望能够以不同于 y 轴的方式设置工具提示中的文本格式。 y 轴不显示分。我只想在工具提示上显示美分。格式化完成...
我找到了一个示例工具提示 html css,它正是我正在寻找的。但我不想显示文本,而是想显示图像。链接在这里。 代码笔链接 我们也可以在数据上显示图像吗...
为什么 Plotly.js 散点图中工具提示显示在错误的点上?
我在 Plotly 社区发布了这个问题:https://community.plotly.com/t/why-does-the-tooltip-show-on-the-wrong-point-in-scatter-plot/ 78835。我再次在这里发布以获得更多
我有一个链接,当用户有一些新通知时,我将使用该链接作为通知,我将通过显示工具提示(twitter bootstrap 工具提示)来通知用户。我想要实现的是...
我想在单击时显示工具提示,而不是长按时显示。 谁能帮我这个? 工具提示( 消息:e.title, 孩子:卡( 语义容器:true, 孩子:填充( 填充:
我是个新人,但在此处搜索并尝试禁用 CodeLens 后并没有解决我的问题。 我从 VsCode 中的 python 数据科学开始,例如,如果我要创建一个 Numpy 数组,它会显示...
我用 Material UI 实现了一个工具提示,但字体太小了。我无法用 .scss 更改它。 从“反应”导入反应; 导入“./InfoTooltip.scss”; 导入信息图标
我在文本顶部显示工具提示,让用户看到人员的全名,但无论文本是否溢出,它都会显示工具提示: 子项:工具提示( 消息:fullNameWit...
我想在 Angular 16 上使用 MatTooltip 添加一个箭头。但是由于某种原因,使用箭头的伪元素覆盖材质并不像许多帖子中建议的那样工作。 这是我的同事...
使用Bootstrap工具提示时,我们需要编写这样的代码才能具有工具提示功能: $(".showtooltip").tooltip(); 但问题是,每次新的 c 时,我们都需要重新运行该代码...
我有一个有两列的农业网格表。对于第一列,我显示名称和区域。当用户将鼠标悬停在名称和区域上时,我希望名称显示在工具提示中。 ...
应用工具提示菜单选项后,显示在窗口中的不同位置,而不是材料 ui 中的按钮图标下方。同样的问题怎么解决
我正在尝试将工具提示应用于选项菜单图标,但它没有按我预期的方式工作。 我的代码是: 导出默认函数 FadeMenu() { const [anchorEl, setAnchorEl] = React.useState(null) ...
创建自定义语音气泡工具提示,根据每种情况调整/放置其箭头/指针
我有一个 WPF 语音气泡工具提示,运行良好。 <Setter Property="OverridesDefaultStyle" ...</desc> <question vote="0"> <p>我有一个 WPF 语音气泡工具提示,运行良好。</p> <pre><code><Style x:Key="{x:Type ToolTip}" TargetType="ToolTip"> <Setter Property="OverridesDefaultStyle" Value="true" /> <Setter Property="HorizontalOffset" Value="1" /> <Setter Property="VerticalOffset" Value="1" /> <Setter Property="Background" Value="White" /> <Setter Property="Foreground" Value="Black" /> <Setter Property="FontSize" Value="12" /> <Setter Property="FontFamily" Value="Segoe UI" /> <Setter Property="DataContext" Value="{Binding Path=PlacementTarget.DataContext, RelativeSource={x:Static RelativeSource.Self}}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ToolTip"> <Canvas Width="225" Height="131"> <Path x:Name="Container" Canvas.Left="0" Canvas.Top="0" Margin="0" Data="M8,7.41 L15.415,0 L22.83,7.41 L224,7.41 L224,130 L0,130 L0,7.41 L8,7.41" Fill="{TemplateBinding Background}" Stroke="Gray"> <Path.Effect> <DropShadowEffect BlurRadius="10" Opacity="0.5" ShadowDepth="4" /> </Path.Effect> </Path> <TextBlock Canvas.Left="10" Canvas.Top="10" Width="100" Height="65" Text="{TemplateBinding Content}" TextWrapping="WrapWithOverflow" /> </Canvas> </ControlTemplate> </Setter.Value> </Setter> </Style> </code></pre> <p>上述方法的问题是,无论情况如何,语音气泡工具提示(路径)的箭头/指针始终放置在相同的位置,我希望它适应情况并使用以下之一(以上样式实现箭头位于左上角,下面屏幕截图中的第一个工具提示):</p> <p><a href="https://i.stack.imgur.com/T2MdB.png" target="_blank"><img src="https://cdn.imgupio.com/i/AWkuc3RhY2suaW1ndXIuY29tL1QyTWRCLnBuZw==" alt=""/></a></p> <p>我该怎么做?可以吗?</p> </question> <answer tick="false" vote="1"> <p>这是此任务的完整代码:</p> <pre><code>using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace Decorators { public enum Position { None, Top, Bottom, RightSide, LeftSide, } public enum SpecificPosition { None, LeftOrTop = 25, Center = 50, RightOrBottom = 75, } internal class BubbleTextDecorator : Decorator { #region DependencyProperties public static readonly DependencyProperty VerticalMarginProperty = DependencyProperty.Register("VerticalMargin", typeof(double), typeof(BubbleTextDecorator), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)); public double VerticalMargin { get { return (double)GetValue(VerticalMarginProperty); } set { SetValue(VerticalMarginProperty, value); } } public static readonly DependencyProperty HorizontalMarginProperty = DependencyProperty.Register("HorizontalMargin", typeof(double), typeof(BubbleTextDecorator), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)); public double HorizontalMargin { get { return (double)GetValue(HorizontalMarginProperty); } set { SetValue(HorizontalMarginProperty, value); } } public static readonly DependencyProperty PointerPositionProperty = DependencyProperty.Register("PointerPosition", typeof(Position), typeof(BubbleTextDecorator), new FrameworkPropertyMetadata(Position.None, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure)); public Position PointerPosition { get { return (Position)GetValue(PointerPositionProperty); } set { SetValue(PointerPositionProperty, value); } } public static readonly DependencyProperty AlignmentPositionProperty = DependencyProperty.Register("AlignmentPosition", typeof(SpecificPosition), typeof(BubbleTextDecorator), new FrameworkPropertyMetadata(SpecificPosition.None, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure)); public SpecificPosition AlignmentPosition { get { return (SpecificPosition)GetValue(AlignmentPositionProperty); } set { SetValue(AlignmentPositionProperty, value); } } public static readonly DependencyProperty PointerHeightProperty = DependencyProperty.Register("PointerHeight", typeof(double), typeof(BubbleTextDecorator), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)); public double PointerHeight { get { return (double)GetValue(PointerHeightProperty); } set { SetValue(PointerHeightProperty, value); } } public static readonly DependencyProperty PointerWidthProperty = DependencyProperty.Register("PointerWidth", typeof(double), typeof(BubbleTextDecorator), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsRender)); public double PointerWidth { get { return (double)GetValue(PointerWidthProperty); } set { SetValue(PointerWidthProperty, value); } } #endregion protected override Size ArrangeOverride(Size arrangeSize) { Size desiredSize = base.ArrangeOverride(arrangeSize); if (Child != null) { switch (PointerPosition) { case Position.Top: Child.Arrange(new Rect(new Point(0.0, PointerHeight), new Point(desiredSize.Width, desiredSize.Height))); break; case Position.Bottom: Child.Arrange(new Rect(new Point(0.0, 0.0), new Point(desiredSize.Width, desiredSize.Height - PointerHeight))); break; case Position.LeftSide: Child.Arrange(new Rect(new Point(PointerHeight, 0.0), new Point(desiredSize.Width, desiredSize.Height))); break; case Position.RightSide: Child.Arrange(new Rect(new Point(0.0, 0.0), new Point(desiredSize.Width - PointerHeight, desiredSize.Height))); break; } } return arrangeSize; } protected override Size MeasureOverride(Size constraint) { Size desiredSize = base.MeasureOverride(constraint); Size size = (PointerPosition == Position.Top || PointerPosition == Position.Bottom) ? new Size(desiredSize.Width + (HorizontalMargin * 2), desiredSize.Height + (VerticalMargin * 2) + PointerHeight) : new Size(desiredSize.Width + (HorizontalMargin * 2) + PointerHeight, desiredSize.Height + (VerticalMargin * 2)); return size; } protected override void OnRender(DrawingContext drawingContext) { Brush renderBrush = Brushes.Transparent; Pen renderPen = new Pen(Brushes.Black, 1); StreamGeometry geom = new StreamGeometry(); switch (PointerPosition) { case Position.Top: DrawTop(geom); break; case Position.Bottom: DrawBottom(geom); break; case Position.RightSide: DrawRight(geom); break; case Position.LeftSide: DrawLeft(geom); break; } // Some arbitrary drawing implements. drawingContext.DrawGeometry(renderBrush, renderPen, geom); } private void DrawLeft(StreamGeometry geom) { using (StreamGeometryContext ctx = geom.Open()) { ctx.BeginFigure( new Point(PointerHeight, 0.0), true, true); ctx.LineTo( new Point(ActualWidth, 0.0), true, false); ctx.LineTo( new Point(ActualWidth, ActualHeight), true, false); ctx.LineTo( new Point(PointerHeight, ActualHeight), true, false); ctx.LineTo( new Point(PointerHeight, (ActualHeight * (double)AlignmentPosition / 100) + (PointerWidth / 2)), true, false); ctx.LineTo( new Point(0.0, ActualHeight * (double)AlignmentPosition / 100), true, false); ctx.LineTo( new Point(PointerHeight, (ActualHeight * (double)AlignmentPosition / 100) - (PointerWidth / 2)), true, false); ctx.LineTo( new Point(PointerHeight, 0.0), true, false); } } private void DrawRight(StreamGeometry geom) { using (StreamGeometryContext ctx = geom.Open()) { ctx.BeginFigure( new Point(0.0, 0.0), true, true); ctx.LineTo( new Point(ActualWidth - PointerHeight, 0.0), true, false); ctx.LineTo( new Point(ActualWidth - PointerHeight, (ActualHeight * (double)AlignmentPosition / 100) - (PointerWidth / 2)), true, false); ctx.LineTo( new Point(ActualWidth, ActualHeight * (double)AlignmentPosition / 100), true, false); ctx.LineTo( new Point(ActualWidth - PointerHeight, (ActualHeight * (double)AlignmentPosition / 100) + (PointerWidth / 2)), true, false); ctx.LineTo( new Point(ActualWidth - PointerHeight, ActualHeight), true, false); ctx.LineTo( new Point(0.0, ActualHeight), true, false); ctx.LineTo( new Point(0.0, 0.0), true, false); } } private void DrawBottom(StreamGeometry geom) { using (StreamGeometryContext ctx = geom.Open()) { ctx.BeginFigure( new Point(0.0, 0.0), true, true); ctx.LineTo( new Point(ActualWidth, 0.0), true, false); ctx.LineTo( new Point(ActualWidth, ActualHeight - PointerHeight), true, false); ctx.LineTo( new Point((ActualWidth * (double)AlignmentPosition / 100) + (PointerWidth / 2), ActualHeight - PointerHeight), true, false); ctx.LineTo( new Point(ActualWidth * (double)AlignmentPosition / 100, ActualHeight), true, false); ctx.LineTo( new Point((ActualWidth * (double)AlignmentPosition / 100) - (PointerWidth / 2), ActualHeight - PointerHeight), true, false); ctx.LineTo( new Point(0.0, ActualHeight - PointerHeight), true, false); ctx.LineTo( new Point(0.0, 0.0), true, false); } } private void DrawTop(StreamGeometry geom) { using (StreamGeometryContext ctx = geom.Open()) { ctx.BeginFigure( new Point(0.0, PointerHeight), true, true); ctx.LineTo( new Point((ActualWidth * (double)AlignmentPosition / 100) - (PointerWidth / 2), PointerHeight), true, false); ctx.LineTo( new Point(ActualWidth * (double)AlignmentPosition / 100, 0.0), true, false); ctx.LineTo( new Point((ActualWidth * (double)AlignmentPosition / 100) + (PointerWidth / 2), PointerHeight), true, false); ctx.LineTo( new Point(ActualWidth, PointerHeight), true, false); ctx.LineTo( new Point(ActualWidth, ActualHeight), true, false); ctx.LineTo( new Point(0.0, ActualHeight), true, false); ctx.LineTo( new Point(0.0, PointerHeight), true, false); } } } } </code></pre> <p>这就是你如何使用它:</p> <pre><code><localdecorators:BubbleTextDecorator PointerHeight="10" PointerWidth="20" PointerPosition="LeftSide" AlignmentPosition="Center" VerticalMargin="30" HorizontalMargin="30" HorizontalAlignment="Left"> <TextBlock Text="this" HorizontalAlignment="Center" VerticalAlignment="Center"/> </localdecorators:BubbleTextDecorator> </code></pre> <p><a href="https://i.stack.imgur.com/0ycsH.png" target="_blank"><img src="https://cdn.imgupio.com/i/AWkuc3RhY2suaW1ndXIuY29tLzB5Y3NILnBuZw==" alt=""/></a></p> </answer> <answer tick="false" vote="0"> <p>目前我正在努力解决同样的问题。 您已经有解决这个问题的方法了吗?</p> <p>致以诚挚的问候</p> </answer> <answer tick="false" vote="-1"> <p>这是创建Decorator的典型案例。我曾经围绕文本制作了一个可定制的 ArrowBorder。你需要继承Decorator类。</p> <pre><code>internal class ArrowBorderDecorator : Decorator </code></pre> <p>然后你需要一些 DependencyProperties 以便于自定义。 在我的例子中,这是 <pre><code>ArrowTipToArrowTriangleBaseDistance</code></pre> 属性,这意味着箭头应该有多“尖”。在你的例子中,气泡文本箭头应该在哪里。</p> <pre><code> public static readonly DependencyProperty ArrowTipToArrowTriangleBaseDistanceProperty = DependencyProperty.Register("ArrowTipToArrowTriangleBaseDistance", typeof(double), typeof(ArrowBorderDecorator), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)); public double ArrowTipToArrowTriangleBaseDistance { get { return (double)GetValue(ArrowTipToArrowTriangleBaseDistanceProperty); } set { SetValue(ArrowTipToArrowTriangleBaseDistanceProperty, value); } } </code></pre> <p>然后您需要重写 <pre><code>ArrangeOverride</code></pre>、<pre><code>MeasureOverride</code></pre> 和 <pre><code>OnRender</code></pre> 方法。前两个来自 Decorator 类,第三个来自 UIElement 类。</p> <p>这里有一个很好的<a href="https://stackoverflow.com/questions/66818340/measureoverride-and-arrangeoverride-what-is-really-availablesize-desiredsize">链接</a>来理解前两个。 在 <pre><code>OnRender</code></pre> 中,您有一个 DrawingContext,可以使用 DependenyProperties 绘制所需的形状。</p> <p>在这些之后,您可以像这样在 xaml 中使用装饰器:</p> <pre><code><localdecorators:ArrowBorderDecorator ArrowBaseHalfSegment="0" FillColor="{DynamicResource MahApps.Brushes.Accent3}" StrokeColor="{DynamicResource MahApps.Brushes.ThemeForeground}" ArrowBorderThickness="1" ArrowTipToArrowTriangleBaseDistance="10"> <TextBlock Text="{Binding Path=Title}" Foreground="{DynamicResource MahApps.Brushes.IdealForeground}" Padding="10 1 10 1" VerticalAlignment="Center" FontWeight="Bold"> </TextBlock></localdecorators:ArrowBorderDecorator> </code></pre> <p><a href="https://i.stack.imgur.com/bETwO.png" target="_blank"><img src="https://cdn.imgupio.com/i/AWkuc3RhY2suaW1ndXIuY29tL2JFVHdPLnBuZw==" alt=""/></a> <a href="https://i.stack.imgur.com/njfyp.png" target="_blank"><img src="https://cdn.imgupio.com/i/AWkuc3RhY2suaW1ndXIuY29tL25qZnlwLnBuZw==" alt=""/></a></p> </answer> </body></html>
我正在使用 "@floating-ui/react": "^0.25.4" 并且在调用 useFloating 钩子时,我没有在钩子调用的结果中获得 floatStyles 属性/字段(即使它没有标记...
我尝试通过在 matTooltipClass 中分配以下 css 属性来使 mat 工具提示可滚动 溢出-y:滚动; 最大高度:200px; 但这是行不通的。谁能建议如何制作 matTool...
将带有 svg 的 html 表格添加到 d3 树形图的工具提示中
我正在做一个可视化 Web 应用程序,它使用 d3 树形图呈现数据。 当用户将鼠标悬停在树状图上时,会出现一个工具提示,将数据显示为包含许多行和列的表格...
我使用此页面 https://web.dev/patterns/clipboard/paste-text/ 中的相同代码,按下它时会在 safari 中呈现工具提示,并且用户必须按下工具提示才能粘贴文本。它确实...
WPF 与 WinForms Oxyplot 自定义工具提示/跟踪器
我正在构建一个 WPF 应用程序并使用 OxyPlot 渲染图表。 为了最大化图表的性能,我切换到OxyPlot.WindowsForms并使用WindowsFormsH嵌入图表...
在此输入图像描述 例如- 在此图像中,当我将鼠标悬停在左侧的按钮(单击)上时,工具提示将离开红色边框容器。 同样的事情也发生在右边......
我当前项目中的工具提示代码如下: HTML: 我当前项目中的工具提示代码如下: HTML: <div class="tooltip"> <img class="icons" src="(...)" alt="Icon"/> <span class="tooltip--text"> Hover-Text <span class="tooltip--text--arrow"></span> </span> </div> 萨斯: &--tooltip { cursor: pointer; position: relative; display: inline-block; &:hover { .tooltip--text { visibility: visible; opacity: 1; } } &--text { position: absolute; z-index: 1; visibility: hidden; width: 120px; max-width: 200px; background-color: #000; color: #fff; text-align: center; border-radius: 4px; padding: 3px 8px; margin-top: -3px; opacity: 0; transition: .3s; top: -45%; left: 45%; transform: translate(-50%, -50%); &--arrow { position: absolute; width: 0; height: 0; border-color: transparent; border-style: solid; bottom: -5px; left: 50%; margin-left: -5px; border-width: 5px 5px 0; border-top-color: #000 } } } 只要工具提示的文本在一行中,一切都可以根据需要完美运行。但是当工具提示有更多行时,工具提示的位置是错误的,我不知道如何解决这个问题。 如有任何帮助,我们将不胜感激,并提前致谢! .tooltip--text { position: absolute; z-index: 1; visibility: hidden; width: 120px; max-width: 200px; background-color: #000; color: #fff; text-align: center; border-radius: 4px; padding: 3px 8px; margin-top: -3px; opacity: 0; transition: .3s; bottom: 100%; left: 45%; transform: translateX(-50%); }