我正在编写一个小程序,它基本上有一堆按钮,当你点击一个按钮时,它会在我玩的在线游戏中输入一行文本。如果 GUI 保持在活动游戏窗口的顶部,那么使用起来会容易得多,这样用户就可以玩游戏,然后按下面板上的按钮,而不必先把它带到前面。
关于如何做到这一点的任何帮助都会很棒。谢谢
编辑:使用 tkinter
我有一个表单,其中包含表单中的文件输入,更重要的是一个取消按钮,它应该取消文件上传:
var $fileImage = $("<form action='imageupload.php' method='post' class='imageuploadform' ...><label>" +
"Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><label>" +
"<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" +
"</p><p class='imagef1_cancel' align='center'><label>" +
"<input type='button' name='cancelImageBtn' class='cancelimage' value='Cancel' /></label>" +
"</p></form>");
Run Code Online (Sandbox Code Playgroud)
现在我已经完成了将文件上传到服务器的所有工作。但我有一个问题。
我的问题是我不知道如何取消和上传。目前,如果用户单击“取消”按钮,则什么也不会发生。我想要发生的是,如果用户单击“取消”按钮,那么它将导航到“stopImageUpload()”函数并停止文件上传。但是我该怎么做呢?
下面是我尝试创建取消按钮功能,但是当单击“取消”按钮时,没有任何反应。
$(".cancelimage").on("click", function(event) {
console.log("clicked");
event.preventDefault();
stopImageUpload(success);
});
Run Code Online (Sandbox Code Playgroud)
下面是完整的代码,显示了取消按钮功能的位置以及开始上传和停止上传文件的功能:
function startImageUpload(imageuploadform){
$(imageuploadform).find('.imagef1_upload_process').css('visibility','visible');
sourceImageForm = imageuploadform;
$(".cancelimage").on("click", function(event) {
console.log("clicked");
event.preventDefault();
stopImageUpload(success);
});
return true;
}
function stopImageUpload(success){
var result = '';
if (success == 1){
result = '<span class="msg">The file was …Run Code Online (Sandbox Code Playgroud) 我正在制作一个动态表,每当单击添加行按钮时都会添加行。我正在以编程方式创建按钮并将其添加到表头。在该按钮下方,在同一列上也会有删除行按钮。
但是我遇到了问题,当我单击按钮时,没有调用该事件。我是否正确创建了按钮?如果没有,那我该怎么做?如果我是,那么你知道问题是什么吗?
TableHeaderCell thcOne = new TableHeaderCell();
TableHeaderCell thcTwo = new TableHeaderCell();
TableHeaderCell thcThree = new TableHeaderCell();
TableHeaderCell thcrFour = new TableHeaderCell();
TableHeaderCell thcFive = new TableHeaderCell();
TableCell thcRowAction = new TableCell(); //THIS IS THE COLUMN WITH THE
//ADD BUTTON
thcOne.Text = "Who";
thcTwo.Text = "Date Started";
thcThree.Text = "Date Ended";
thcrFour.Text = "Causes?";
thcFive.Text = "Result";
//HERE IS WHERE I CREATE AND ADD THE BUTTON
Button addRowButton = new Button();
addRowButton.Text = "Add Row";
addRowButton.Click += new …Run Code Online (Sandbox Code Playgroud) 嗨,我有一个绑定到 xml 文件的列表框,每个项目我都给了他们一个按钮数据模板,这样我就可以轻松地为每个项目注册一个点击事件。
我很想得到点击按钮的内容来做一些查询。
这是我的代码
XAML
<ListBox Name="listBox1" >
<ListBox.ItemsSource>
<Binding Source="{StaticResource keywordLib}" XPath="Position/Keyword/Word"/>
</ListBox.ItemsSource>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Content="{Binding}" Click="keyword_Click"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
经过数小时的谷歌搜索解决方案。我知道我应该使用 click 事件中的 sender,这对于普通按钮来说效果很好,这里没有说。
private void keyword_Click(Object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
String keyword = btn.Content.ToString();
MessageBox.Show(keyword);
}
Run Code Online (Sandbox Code Playgroud)
消息框显示“System.Xml.XmlElement”。而不是按钮内容。
非常感谢任何人可以帮助我解决这个问题。我在这方面花了很多钱,我可以猜到解决方案只是一行代码。
我想设计按钮和链接的样式以使其看起来相同,总的来说我已经做到了。但我不能让按钮和链接看起来完全一样:
听起来微不足道,但是当按钮和链接放在一起时,很容易将其视为设计中的错误(我在布局损坏的地方添加了红线)。登录按钮是真正的提交表单的按钮,注册是一个链接到注册页面,看起来像一个按钮。

这里的登录按钮是 106x21 像素,注册链接是 110x25 像素。
以下是我的风格:
a.button,
button {
display: inline-block;
width: 110px;
height: 25px;
padding: 0;
margin: 0;
color: white;
background: #7dbedb; /* Old browsers */
background: -moz-linear-gradient(top, #7dbedb 0%, #95c3ea 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7dbedb), color-stop(100%,#95c3ea)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #7dbedb 0%,#95c3ea 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #7dbedb 0%,#95c3ea 100%); /* Opera 11.10+ */
background: …Run Code Online (Sandbox Code Playgroud) 我想制作一个应用程序,每当我触摸屏幕时,屏幕一开始应该是空白的,就会创建一个按钮并弹出到屏幕上。所以我在这里尝试的是在 main.xml 中创建一个按钮并通过 id 调用它。然后我应用了这个方法。
public class TouchButtonActivity extends Activity {
Button b;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b=(Button) findViewById(R.id.b1);
b.setOnTouchListener(nextListener);
}
public OnTouchListener nextListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
float x = event.getX()*event.getXPrecision();
float y = event.getY()*event.getYPrecision();
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
p.gravity = Gravity.TOP;
p.leftMargin = (int) x;
p.topMargin = (int) y;
b.setLayoutParams(p); …Run Code Online (Sandbox Code Playgroud) 我想知道让纯文本充当按钮(使用最少的 html)的最简单方法是什么。文本:
<li class="indiv-nav" ><a target="_blank" href="/">About</a></li>
我需要有关执行以下内容的文本:
<div id="button"><input type="submit" value="Press me please!" /></div>
对不起,如果这是一个“愚蠢”的问题,但是,我仍在学习,我发现没有比我从谷歌搜索中找到的“更简单”的解决方案很疯狂。
我有一个提交按钮,我想在该按钮上显示一个图像(a.jpg)并且不会显示提交按钮的值。在“提交”类型按钮的情况下是否可能?(不是“type='image'”)
<input type="submit" value="submit" />
Run Code Online (Sandbox Code Playgroud)
-谢谢。
使用 JSF 创建按钮以调用 JS 函数的首选方法是什么?
其实我用:
<p:button onclick="myJSFunction();" href="#"/>
Run Code Online (Sandbox Code Playgroud)
但我的网址后缀为锚符号 ( #)。
是否有另一种推荐的方法来创建不会重新加载/导航到 URL 而是调用 JS 函数的按钮?
我想使用单个 div 创建一个六边形形状的 CSS 按钮,以保持标记干净。我一直在试验前后伪元素,可以用顶部和底部的六边形“点”来做,但我想用它们向左和向右指向以适应我主题的其余部分。我已经接近了,但我无法在我想要的地方获得 after 伪元素。任何人都可以解决这个问题吗?
这是我要做的:
#hex {
background-color:green;
width:100px;
height:100px;
float:left;
display:block;
}
#hex::before {
content:"";
border-top:50px solid red;
border-bottom:50px solid red;
border-right:30px solid blue;
float:left;
}
#hex::after {
content:"";
border-top:50px solid red;
border-bottom:50px solid red;
border-left:30px solid blue;
float:left;
}
Run Code Online (Sandbox Code Playgroud)
并且在http://jsfiddle.net/higginbottom/YKx2M/有一个 JS Fiddle
button ×10
css ×3
html ×2
javascript ×2
android ×1
asp.net-2.0 ×1
css-shapes ×1
file-upload ×1
jquery ×1
jsf ×1
listbox ×1
onclick ×1
primefaces ×1
python ×1
submit ×1
touch ×1
wpf ×1