button 相关问题

按钮是图形用户界面中的简单元素,可以将鼠标点击或手指点击(在移动设备上)作为输入。

如何更改 TWebButton 组件上的边框颜色?

我可以使用组件上的 Color 属性更改按钮的背景颜色,但我没有看到用于更改边框颜色的属性。 您可以在这里看到该按钮有边框,但是...

回答 1 投票 0

如何避免切换视图递归onChange调用SwiftUI

HStack{ ForEach($rs.newsCategoryCollection){ $类别中 切换(category.id,isOn:$category.isSelected) .toggleStyle(.button) .onChange(of:category.isSelected) {值在 ...

回答 1 投票 0

如何避免递归 onChange 调用 SwiftUI

HStack{ ForEach($rs.newsCategoryCollection){ $类别中 切换(category.id,isOn:$category.isSelected) .toggleStyle(.button) .onChange(of:category.isSelected) {值在 ...

回答 1 投票 0

按钮未显示 jetpack compose android

我有一个可组合项,其中有一个 TextField 和它下面的一个按钮。文本字段按预期显示并工作,但该文本字段下方的按钮根本不显示。这是...

回答 1 投票 0

如何根据单元格中的日期加上 1 个月隐藏一行?

我有一个电子表格,用于跟踪用于筹款的电视节目。我设置了一个带有脚本的按钮,用于隐藏包含过期程序的行(K 列),该程序查看今天的日期...

回答 1 投票 0

向 Windows 窗体添加圆形按钮

我在 Windows 窗体中创建了一个圆形按钮。按钮没问题。唯一的问题是我希望它的颜色与背景不同,所以我将 BackColor 设置为 GoldenRod。然而,它很...

回答 2 投票 0

仅使用 JavaScript 单击按钮即可增加字体大小

我正在尝试通过单击按钮来增加字体大小。我已经让第一个可以工作了,但我无法理解第二个。第二个,每次点击都会增加fo...

回答 7 投票 0

Python 单击 Redfin 收藏夹和 X-Out 按钮

对于个人用途,我想使用我的 Python Selenium 代码单击 Redfin 的“收藏夹”或“X-Out”按钮,但我无法以编程方式找到这两个按钮,并且我已经尝试了 2 天。我看得出来,但是...

回答 1 投票 0

脚本 - 对于两个单选按钮和最后一个文本字段中的结果必须根据单选按钮和两个字段的值更改颜色

抱歉,我的脚本知识很差。我知道如何设置表单中字段和文本的属性,但我对脚本不太有信心。 我有一个 PDF 表单、两个单选按钮、OptionA 和 Op...

回答 1 投票 0

水平行中按钮的垂直偏移

问题描述: 尽管按钮元素的上边距相等,但它们之间存在垂直偏移。 如果更改 margin-top: 属性,则整行按钮都会移动,而不是一个

回答 1 投票 0

JavaFX - 从禁用转换为启用按钮

父类的控制器 该类包含 3 个按钮“btnSocieta”、“btnUnitaLocali”、“btnReparti”。 第一个是默认启用的,其他两个是禁用的。 在 stackPane 中我显示起始页

回答 1 投票 0

Jetpack Compose Android 按钮检测长按

如何检测长按 按钮( onClick = onClick, 交互源=交互源, 修饰符 = 修饰符 .combinedClickable( onClick = onClick,

回答 2 投票 0

ion-fab 按钮与其他离子组件重叠

我正在使用 ion-fab 列表来保存 ion-fab 按钮,但问题是 ion-fab 按钮与 ion-list(下面的日期选择器)/ion-button 重叠,无论应用内联边距样式、 ion-项目-

回答 1 投票 0

如何在Python中对每次点击做出true-false?

我正在尝试在Python项目中提高自己,但我陷入了困境。问题是;我希望每次用鼠标左键单击时,我定义的全局变量都会更改为 true-false。那个...

回答 1 投票 0

我可以制作一个 svg 图像按钮吗?

有什么方法可以在单击 svg 图像时发出 POST 请求吗? 到目前为止我最好的尝试如下: 有什么方法可以在单击 svg 图像时发出 POST 请求吗? 迄今为止我最好的尝试如下: <form action="/test-button" method="POST"> <input name="Submit" type="submit" value="Submit" /> <svg > <rect width="100" height="100" > </svg> </form> 这是一个黑色矩形,旁边有一个提交按钮。 我想让人们在多个图像之间进行选择,所以这可能是一个不错的解决方案,但是有没有办法制作一个图像,当单击时,会触发一个帖子? 不使用javascript可加分。 警告:这有点 hacky,但据我所知它 100% 合法,并且不需要 javascript。 由于 label 元素也可用于控制其关联的输入,因此您可以尝试如下操作: <form action="/test-button" method="POST"> <label> <input type="submit" name="image" value="one"> <svg><rect width="100" height="100"></rect></svg> </label> <label> <input type="submit" name="image" value="two"> <svg><rect width="100" height="100"></rect></svg> </label> </form> ​ 然后用CSS隐藏提交按钮。您可以在标签中添加任何您想要的内容。 当您单击标签中的任何内容时,它将触发其中的提交按钮并提交表单,按钮的 value 位于 POST 数组中。 还有一个 <input type="image">,但它的目的完全不同(跟踪单击位置的坐标)。 这似乎是 <button> 元素的一个很好的用例。 <form action="/test-button" method="POST"> <button> <svg> <rect width="100" height="100" > </svg> </button> </form> 单击按钮元素执行与 input[type="submit"] 完全相同的工作,因此您可以完全替换输入。如果您选择这条路线,您还可以考虑在按钮内放置一个文本标签和/或在 svg 内放置一个 title 以实现辅助功能。 这个,也许: <form action="/test-button" method="POST"> <input type="image" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIi8+PC9zdmc+"> </form> Jsfiddle:http://jsfiddle.net/Xawuv/ 没有 JS 是不可能的,但是你可以用 JS 来做。附上 onclick(),只需使用:document.getElementById('formID').submit();。 HTML: <form action="/test-button" method="POST" id="submittingForm"> <input name="Submit" type="submit" value="Submit" /> <svg onclick="submitForm();"> <rect width="100" height="100" > </svg> </form> 和 JS(位于您的 <head></head> 标签内): <script type="text/javascript"> function submitForm() { document.getElementById("submittingForm").submit(); } </script> 这是一个简单的按钮,盒子内有一个闪电。 <svg x="167" y="8" cursor="pointer" width="30" height="30" visibility="visible" > <g id="Flash"> <g fill="#FFCC00" stroke="#D57300" stroke-width="2" > <path stroke-linecap="round" d="m 10.311873 9.0776039 9.400261 -7.988867 -0.05562 6.2501137 -2.224914 0.093987 -0.05562 5.5452134 11.402682 -0.04699 -18.522406 16.024725 0.05562 -6.015145 2.169291 -0.09398 -0.05562 -5.874165 -11.51392928 0.04699 z"/> </g> </g> <rect width="30" height="30" opacity="0" fill="transparent" fill="url(#Flash)" id="Flash_Button" onclick="Flash(evt);" /> </svg> 这是当您单击 时该功能的脚本 function Flash(){ // post whatever you want inside here } 当您创建一个按钮并且其内部有线条时,问题是当您将 onclick 放入父元素时,您不会单击所有 svg 元素,而是单独单击其中的所有子元素。所以你需要在 svg 内创建一个具有父元素宽度和高度的矩形并将其隐藏,然后放置 onclick! 有些答案忘记隐藏输入。这应该可以完美地工作: 只需复制粘贴即可。 <label class="cursor: pointer;"> <input type="submit" name="mysubmit" value="val1" style="display: none;"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-down-up" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M11.5 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L11 2.707V14.5a.5.5 0 0 0 .5.5zm-7-14a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4- 4a.5.5 0 0 1 .708-.708L4 1 3.293V1.5a.5.5 0 0 1 .5-.5z"/> </svg> </label> 只需将 onClick 添加到 svg <svg onClick={addAddress}> ..... </svg>

回答 7 投票 0

在 ControlTemplate 中绑定附加属性

<Setter Property="Height" Value="22"/> <Setter Property="Padding" </desc> <question vote="0"> <pre><code>&lt;Style x:Key=&#34;DeckButton_Help&#34; TargetType=&#34;{x:Type Button}&#34;&gt; &lt;Setter Property=&#34;Height&#34; Value=&#34;22&#34;/&gt; &lt;Setter Property=&#34;Padding&#34; Value=&#34;0,0&#34;/&gt; &lt;Setter Property=&#34;Margin&#34; Value=&#34;0,0&#34;/&gt; &lt;Setter Property=&#34;Content&#34; Value=&#34;&#34;/&gt; &lt;Setter Property=&#34;local:ButtonProperties.ImageSource&#34; Value=&#34;&#34;/&gt; &lt;Setter Property=&#34;Template&#34;&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType=&#34;{x:Type Button}&#34;&gt; &lt;Button Style=&#34;{StaticResource ButtonForeground}&#34; HorizontalContentAlignment=&#34;Left&#34; Background=&#34;#e1e1e1&#34; BorderBrush=&#34;#9d9d9d&#34; Command=&#34;{TemplateBinding Command}&#34; Padding=&#34;5,4,0,0&#34; &gt; &lt;Button.Content&gt; &lt;Grid Height=&#34;16&#34;&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width=&#34;16&#34;/&gt; &lt;ColumnDefinition Width=&#34;*&#34;/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Image Style=&#34;{StaticResource ButtonImage}&#34; Height=&#34;16&#34; Width=&#34;16&#34; Source=&#34;{TemplateBinding local:ButtonProperties.ImageSource}&#34; VerticalAlignment=&#34;Center&#34; HorizontalAlignment=&#34;Left&#34; Margin=&#34;0,-4,0,0&#34;/&gt; &lt;TextBlock Grid.Column=&#34;1&#34; Text=&#34;{TemplateBinding Content}&#34; HorizontalAlignment=&#34;Center&#34; Margin=&#34;5,0,0,0&#34; /&gt; &lt;/Grid&gt; &lt;/Button.Content&gt; &lt;/Button&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>这里我尝试从外部按钮设置 local:ButtonProperties.ImageSource 属性。</p> <pre><code>&lt;Button local:ButtonProperties.ImageSource=&#34;/CommonResources;component/bitmap/IDB_BUTTON_HELP.PNG&#34; Style=&#34;{StaticResource DeckButton_Help}&#34; Command=&#34;{Binding HelpCommand}&#34; Content=&#34;Help&#34; Margin=&#34;20,0,0,0&#34; Width=&#34;65&#34; /&gt; </code></pre> <p>而 ButtonProperties 是这样定义的:</p> <pre><code>public class ButtonProperties { public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.RegisterAttached( &#34;ImageSource&#34;, typeof(string), typeof(ButtonProperties), new FrameworkPropertyMetadata(null)); public static string GetImageSource(DependencyObject obj) { return (string)obj.GetValue(ImageSourceProperty); } public static void SetImageSource(DependencyObject obj, string value) { obj.SetValue(ImageSourceProperty, value); } } </code></pre> <p>问题是图标没有设置,当我调试时,SetImageSource和GetImageSource没有被调用。</p> </question> <answer tick="true" vote="1"> <p>您可以使用常规 Binding 来代替 TemplateBinding,如下所示。它将提供从字符串到 ImageSource 的自动类型转换。</p> <pre><code>&lt;Image ... Source=&#34;{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:ButtonProperties.ImageSource)}&#34;/&gt; </code></pre> <p>如果您正确设置图像路径,这应该可以工作(我已经在我的设备上测试了代码)。</p> <hr/> <p>然而,将附加属性声明为 <pre><code>ImageSource</code></pre> 而不是 <pre><code>string</code></pre> 是有意义的,这样 TemplateBinding 也可以工作。当您在 Button 上分配附加属性时,就会发生从字符串到 ImageSource 的转换,并且附加属性不能包含任何无效字符串。</p> <pre><code>public class ButtonProperties { public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.RegisterAttached( &#34;ImageSource&#34;, typeof(ImageSource), typeof(ButtonProperties)); public static ImageSource GetImageSource(DependencyObject obj) { return (ImageSource)obj.GetValue(ImageSourceProperty); } public static void SetImageSource(DependencyObject obj, ImageSource value) { obj.SetValue(ImageSourceProperty, value); } } </code></pre> <hr/> <p>旁注:</p> <ol> <li>在某些情况下,依赖属性 setter 和 getter 中的断点不会被击中,例如当在 XAML 中设置属性时。框架直接调用SetValue和GetValue。</li> <li>如果<pre><code>string</code></pre>类型的属性的默认值为null,则不需要在属性定义中使用<pre><code>new FrameworkPropertyMetadata(null)</code></pre>,也不需要在样式定义中使用<pre><code>&lt;Setter Property=&#34;local:ButtonProperties.ImageSource&#34; Value=&#34;&#34;/&gt;</code></pre>。</li> </ol> </answer> <answer tick="false" vote="0"> <p>TemplateBinding 不会执行自动类型转换,正如您在 Binding 中所期望的那样</p> <pre><code>Source=&#34;{TemplateBinding local:ButtonProperties.ImageSource} </code></pre> <p>其中源属性的类型为 <pre><code>string</code></pre>,目标属性的类型为 <pre><code>ImageSource</code></pre>。</p> <p>您必须在附加属性的声明中使用正确的类型:</p> <pre><code>public class ButtonProperties { public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.RegisterAttached( &#34;ImageSource&#34;, typeof(ImageSource), typeof(ButtonProperties)); public static ImageSource GetImageSource(DependencyObject obj) { return (ImageSource)obj.GetValue(ImageSourceProperty); } public static void SetImageSource(DependencyObject obj, ImageSource value) { obj.SetValue(ImageSourceProperty, value); } } </code></pre> <hr/> <p>您还必须删除 Setter </p> <pre><code>&lt;Setter Property=&#34;local:ButtonProperties.ImageSource&#34; Value=&#34;&#34;/&gt; </code></pre> <p>来自按钮样式,因为空字符串对于 ImageSource 类型的属性来说不是有效值。</p> <hr/> <p>请注意,当在 XAML 中设置 <pre><code>SetImageSource</code></pre> 属性时,不会调用 <pre><code>ImageSource</code></pre> 方法。框架绕过setter和getter,直接调用<pre><code>SetValue</code></pre>和<pre><code>GetValue</code></pre>。</p> </answer> </body></html>

回答 0 投票 0

绑定Button的ImageSource依赖属性

<Setter Property="Height" Value="22"/> <Setter Property="Padding" </desc> <question vote="0"> <pre><code>&lt;Style x:Key=&#34;DeckButton_Help&#34; TargetType=&#34;{x:Type Button}&#34;&gt; &lt;Setter Property=&#34;Height&#34; Value=&#34;22&#34;/&gt; &lt;Setter Property=&#34;Padding&#34; Value=&#34;0,0&#34;/&gt; &lt;Setter Property=&#34;Margin&#34; Value=&#34;0,0&#34;/&gt; &lt;Setter Property=&#34;Content&#34; Value=&#34;&#34;/&gt; &lt;Setter Property=&#34;local:ButtonProperties.ImageSource&#34; Value=&#34;&#34;/&gt; &lt;Setter Property=&#34;Template&#34;&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType=&#34;{x:Type Button}&#34;&gt; &lt;Button Style=&#34;{StaticResource ButtonForeground}&#34; HorizontalContentAlignment=&#34;Left&#34; Background=&#34;#e1e1e1&#34; BorderBrush=&#34;#9d9d9d&#34; Command=&#34;{TemplateBinding Command}&#34; Padding=&#34;5,4,0,0&#34; &gt; &lt;Button.Content&gt; &lt;Grid Height=&#34;16&#34;&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width=&#34;16&#34;/&gt; &lt;ColumnDefinition Width=&#34;*&#34;/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Image Style=&#34;{StaticResource ButtonImage}&#34; Height=&#34;16&#34; Width=&#34;16&#34; Source=&#34;{TemplateBinding local:ButtonProperties.ImageSource}&#34; VerticalAlignment=&#34;Center&#34; HorizontalAlignment=&#34;Left&#34; Margin=&#34;0,-4,0,0&#34;/&gt; &lt;TextBlock Grid.Column=&#34;1&#34; Text=&#34;{TemplateBinding Content}&#34; HorizontalAlignment=&#34;Center&#34; Margin=&#34;5,0,0,0&#34; /&gt; &lt;/Grid&gt; &lt;/Button.Content&gt; &lt;/Button&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>这里我尝试从外部按钮设置 local:ButtonProperties.ImageSource 属性。</p> <pre><code>&lt;Button local:ButtonProperties.ImageSource=&#34;/CommonResources;component/bitmap/IDB_BUTTON_HELP.PNG&#34; Style=&#34;{StaticResource DeckButton_Help}&#34; Command=&#34;{Binding HelpCommand}&#34; Content=&#34;Help&#34; Margin=&#34;20,0,0,0&#34; Width=&#34;65&#34; /&gt; </code></pre> <p>而 ButtonProperties 是这样定义的:</p> <pre><code>public class ButtonProperties { public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.RegisterAttached( &#34;ImageSource&#34;, typeof(string), typeof(ButtonProperties), new FrameworkPropertyMetadata(null)); public static string GetImageSource(DependencyObject obj) { return (string)obj.GetValue(ImageSourceProperty); } public static void SetImageSource(DependencyObject obj, string value) { obj.SetValue(ImageSourceProperty, value); } } </code></pre> <p>问题是图标没有设置,当我调试时,SetImageSource和GetImageSource没有被调用。</p> </question> <answer tick="false" vote="0"> <p>附加属性应该像这样使用</p> <pre><code>&lt;Image Style=&#34;{StaticResource ButtonImage}&#34; Height=&#34;16&#34; Width=&#34;16&#34; Source=&#34;{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:ButtonProperties.ImageSource)}&#34; VerticalAlignment=&#34;Center&#34; HorizontalAlignment=&#34;Left&#34; Margin=&#34;0,-4,0,0&#34;/&gt; </code></pre> <p>如果您正确设置图像路径,这应该可以工作(我已经在我的设备上测试了代码)。</p> </answer> </body></html>

回答 0 投票 0

SWT - 从 Shell 中的按钮/控件中移除焦点

我有一个包含几个按钮的窗口(该窗口充当起始页)。当我第一次创建并打开 Shell 时,创建的第一个 Button 被分配焦点。有没有办法去掉

回答 3 投票 0

如何实现长按和短按?长按应该是3秒

我正在开发STM32F407VG开发板。我需要使用该处理器来设计产品。我的应用程序包括短按和长按功能。我已经实现了逻辑。布...

回答 1 投票 0

下拉文本框的按钮

我正在尝试使用 CSS/HTML 编写一个按钮,当您单击它时,它会下拉/显示一个文本框。 这是我想要实现的目标的图像:

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.