我希望我的(ExtJS)工具栏按钮在单击时不会抓住网页上的焦点,而是在点击时保持焦点不变的情况下执行"事物".我怎么做?
我希望有一个看起来像按钮的组件,但它应该包含一个图像,而不是文本.由于标准按钮不提供此功能,我尝试使用<h:commandLink>:
<h:commandLink action="#{some_action}">
<p:panel styleClass="some_style">
<h:graphicImage value="#{some_image}">
</p:panel>
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)
这不起作用.将<h:commandLink>被转换成一个<a>标签,和<p:panel>成<div>.<a>-tags可能不包含<div>-tags,因此<div>-tag会自动放在<a>-tag 之外.结果是只有图像是可点击的,而不是周围的面板,其样式看起来像一个按钮.有没有办法让周围的面板成为链接的一部分,或者将图像放在按钮内?
我的项目使用JSF和Primefaces库:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui">
Run Code Online (Sandbox Code Playgroud) 我无法理解这段代码.我得到findViewById它将获得按钮小部件,然后它将投射它.然后,它将使用按钮来调用该setOnClickListener方法.但是,我不知道该传递的内容是什么setOnClickListener,我之前从未见过这样的代码.它是如何创建一个新对象但是能够在另一个方法的参数中创建自己的方法?如果有人能够解释那就好了.此外,该setOnClickListener方法采用何种类型的对象?
btn = (Button)findViewById(R.id.firstButton);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
tv.setText(months[rand.nextInt(12)]);
tv.setTextColor(Color.rgb(rand.nextInt(255)+1, rand.nextInt(255)+1, rand.nextInt(255)+1));
}
});
Run Code Online (Sandbox Code Playgroud) 我试图在WPF中禁用按钮上的MouseOver效果,或者至少更改它的颜色.
我使用以下样式:
<Style x:Key="Borderless" TargetType="{x:Type Button}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Button Background="{TemplateBinding Control.Background}"
Focusable="False">
<ContentPresenter
Margin="{TemplateBinding Control.Padding}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
RecognizesAccessKey="True"
Content="{TemplateBinding ContentControl.Content}" />
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
在Window.Resources中,我认为会覆盖所有默认行为.但事实并非如此.
有什么建议?
我的aspx文件中有一个名为btnTest的按钮..cs文件具有在单击按钮时调用的函数.
btnTest_Click(object sender, EventArgs e)
Run Code Online (Sandbox Code Playgroud)
如何从我的代码中调用此函数(即没有实际单击按钮)?
删除jQuery UI对话框上的关闭按钮的最佳方法是什么?
我不希望人们能够关闭对话框.
我通过处理代码角度覆盖它:
closeOnEscape: false,
beforeclose: function (event, ui) { return false; }
Run Code Online (Sandbox Code Playgroud)
我试图不需要编写脚本来抓取关闭按钮的类/ id,然后手动隐藏它.而且我不想手动更改CSS,因为对话框可能有需要关闭按钮的情况.
我更喜欢以某种方式对话框配置,但要么我不知道如何做,或者对话框根本不允许它.
有关如何配置对话框的任何建议?
在Firefox 3.6中,您可以使用::-moz-focus-inner {border:0;padding:0;margin:0;}删除forms.css添加的默认边距和填充.
如何在Firefox 4中重置此功能?我一直在搜索安装目录中的任何.css文件,这些文件可以为我的按钮添加样式但是找不到ff4的任何内容 - 按钮仍然会获得令人讨厌的1px顶部填充,这将不允许文本与垂直对齐中间.
http://easwee.net/other/FF_problem.gif
编辑:我使用重置样式表,因此无需重置样式.这是一个混乱的浏览器样式表.
如何在几行中逐个创建按钮列表?我做的:
LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout_tags);
for (int i = 1; i < 10; i++) {
Button btnTag = new Button(this);
btnTag.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
btnTag.setText("Button " + i);
btnTag.setId(i);
layout.addView(btnTag);
((Button) findViewById(i)).setOnClickListener(this);
}
Run Code Online (Sandbox Code Playgroud)
并且只有一行:

如何以编程方式进入下一行?
当按钮被禁用时,我希望灰显我的图像(在按钮上).当我在按钮上有文本(没有图像)时,文本显示为灰色(将图像作为按钮内容,它们不会变灰).有没有简单而美丽的方法呢?
这是我的xaml文件:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ToolBarTray VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" IsLocked="true" Grid.Row="0">
<ToolBar Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Band="1" BandIndex="1">
<Button Command="{Binding Button1}" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Button.Content>
<Image Source="open.ico"></Image>
</Button.Content>
</Button>
<Button Command="{Binding Button2}" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Button.Content>
<Image Source="open.ico"></Image>
</Button.Content>
</Button>
</ToolBar>
</ToolBarTray>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
这是我的代码隐藏文件:
public partial class MainWindow : Window
{
private RelayCommand _button1;
private RelayCommand _button2;
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
public ICommand Button1
{
get
{ …Run Code Online (Sandbox Code Playgroud) 使用Bootstrap,当我将一堆元素(例如按钮)放在一行并缩小窗口时,元素会回绕.
但是当窗口足够宽以包含彼此旁边的所有内容时,元素之间存在一些水平空间,垂直所有内容都会粘在一起,其间的空白空间为零像素.
实例(缩小或加宽输出窗口以查看效果)
屏幕截图示例:
1.足够宽,注意按钮之间的空间
2. 环绕,注意彼此顶部堆叠的按钮之间没有空间
我想我可以搞乱一些自定义CSS,添加垂直边距或诸如此类的东西,但为了尽可能保持兼容和标准,我想知道是否有更好或更多的本机方法来修复Bootstrap布局?