我有一个显示数字的标签.用户可以使用两个按钮递增或递减该标签的值.但是,如果用户持有任一按钮,则值将更快或更快地递增或递减.例如,保持1秒快1倍,2秒快2倍,3秒快3倍,依此类推.
这是我尝试但不起作用,因为它不继续调用该方法,你不能看到你UILongGessureRecognizer在一个按钮上分配多个.我需要另一种方法.有任何想法吗?
在我的viewDidLoad中
longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(incrementTwoX)];
longerPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(incrementThreeX)];
[longPressGesture setMinimumPressDuration:1.5];
[longPressGesture setMinimumPressDuration:3];
//add long and longer press gestures to ALL buttons
[weightLeftButton addGestureRecognizer:longPressGesture];
[weightLeftButton addGestureRecognizer:longerPressGesture];
[weightRightButton addGestureRecognizer:longPressGesture];
[weightRightButton addGestureRecognizer:longerPressGesture];
-(void)incrementTwoX{
NSLog(@"Holding");// doesn't get called Im guessing because you can't assign more then one long gesture recognizer to a button
}
-(void)incrementThreeX{
NSLog(@"Holding Longer");
}
- (IBAction)weightRight:(id)sender {
if([weightLabel.text isEqual: @"Not Specified"]) weightLabel.text = 0;
double value = [weightLabel.text doubleValue] + 0.1; …Run Code Online (Sandbox Code Playgroud) 我有窗体和页面布局的问题.我通过以下方式渲染页面:
{% block body -%}
{{ form(edit_form, {'style': 'horizontal'}) }}
<ul class="record_actions">
<li>
<a href="{{ path('organization') }}">
<button type="button" class="btn btn-default">Back to the list</button>
</a>
</li>
<li>
{{ form(delete_form) }}
</li>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
我在ul record_actions上有一些风格.它看起来像这样:http://postimg.org/image/sby8jnojz/
我的问题是更新按钮.我想<ul>用其他2个按钮将它放入标签中.是否有可能将其置于形式之外?我喜欢,表格看起来如何{{ form(edit_form, {'style': 'horizontal'}) }}.所以我不想自定义每个部分{{form_widget}}.或者是否有可能渲染所有表单,然后只渲染此按钮?
我正在开发我的第一个android Calculator应用程序.我遇到了一个缺陷.我添加了几个按钮,单击这些按钮,它会将相应的文本放在EditText字段上.主要问题如下所述,在运行项目时,必须单击两次按钮才能将相应的文本EditText首次放在字段上.例如,点击Button1时在EditText字段上放置"1" .在运行时,首先单击该按钮不执行任何操作.只有在第二次点击时,它才会在EditText字段上显示"1" .
该守则如下,
XML Button和EditField,
<EditText
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:ellipsize="end"
android:ems="10"
android:gravity="right"
android:hint="@string/textView1" />
<Button
android:id="@+id/button1"
android:layout_width="60dp"
android:layout_height="60dp"
android:hint="@string/button1"
android:onClick="set1" />
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
Button onClick的相应功能,
public void set1(View v){
final Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
EditText tv = (EditText) findViewById(R.id.textView1);
String text=tv.getText().toString();
tv.setText(text+"1");
}
});
}
Run Code Online (Sandbox Code Playgroud) 我在Windows Phone 8.1 Store App项目中使用了这段代码(不是Silverlight):
private void CursorRightButton_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrWhiteSpace(QueryTextBox.Text)) return;
QueryTextBox.Focus(FocusState.Keyboard); //also i tried FocusState.Pointer
QueryTextBox.Select((TextBox.SelectionStart + 1) % (TextBox.Text.Length + 1), 0);
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我想以编程方式将光标移动到文本右侧,问题是它隐藏了软键盘,然后在点击按钮后再次显示它.我需要在点击此按钮时打开键盘.
我试图修改发送方和TextBox对象的Focus()方法,但我找不到任何可能的解决方案.
所以问题是,在敲击控件时,如何强制键盘不松动焦点/不隐藏?
我正在使用java8中的javafx开发一个项目.我集中了一个奇怪的情况:一个面板(类javafx.scene.layout.Pane)包含一个按钮(javafx.scene.control.Button)和另一个窗格.我希望鼠标点击的事件可以冒泡到父级.但是,只有在我点击窗格时才会出现这种情况,而单击按钮时则不会发生这种情况.下面是具有此行为的一个非常简单的示例的代码.有没有人有解决这个问题的建议?我知道我可以根据窗格创建自己的按钮..但这只是一个讨厌的解决方法.干杯
package application;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.util.Duration;
public class Main extends Application {
double curScale;
@Override
public void start(Stage primaryStage) {
try {
BorderPane root = new BorderPane();
Scene scene = new Scene(root,400,400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
Button btn = new Button("test");
btn.setLayoutX(50);
Pane p2 = new Pane();
p2.setPrefSize(20,20);
p2.setStyle("-fx-background-color: #440000");
Pane p = new Pane();
p.getChildren().add(btn);
p.getChildren().add(p2);
root.setTop(p);
p.setOnMouseClicked(new EventHandler<Event>() {
@Override …Run Code Online (Sandbox Code Playgroud) 在我的程序中,我有9个按钮,尽管每个事件处理程序中的代码都是相同的,但每个按钮都有9个独立的事件处理程序.事实证明,更改所有这些代码非常繁琐.是否可以创建一个Button.Click事件处理程序来处理所有按钮的Button.Click事件?
我有一个按钮的样式,但我有几个,并希望样式只应用于一个按钮.我该怎么做?
<Style TargetType="{x:Type Button}">
<Setter Property="Background" >
<Setter.Value>
<ImageBrush ImageSource="resources/main_play_normal.png"/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" >
<Setter.Value>
<ImageBrush ImageSource="resources/main_play_over.png"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud) 我试图以编程方式创建一些按钮将它们添加到现有的ViewGroup.这工作正常,但我无法使用正确的样式初始化按钮.
我知道,创建后无法设置/更改视图样式.但到目前为止我发现的所有解决方案都说,使用自定义样式创建视图应该没问题(从我认为的API级别11开始,我使用的是14+):
Button button = new Button (getActivity(), null, R.style.MyButtonStyle);
Run Code Online (Sandbox Code Playgroud)
唯一的效果是,按钮创建时没有任何样式.没有背景,所以选择器,没有边距/填充只是纯文本.我认为MyButtonStyle会被破坏,但是使用MyButtonStyle在XML中创建按钮没问题.
为什么这不起作用?
I am new to using cardlayout and I have a few questions on how to implement it. I first would like to know the best way to implement cardlayout so that I can switch from panel to panel. My main question is how to use buttons inside the constructors of my panels to switch from panel to panel. I just started working on this project today so you will see some code that is not finished or that does not …
我正在寻找一种配置平面无边框按钮的开箱即用方式.这样我就可以在调色板中添加一个按钮并在设计时配置它,而不需要运行时覆盖.我可以使用DevExpress组件,但是我想避免LookAndFeel覆盖或为此创建自定义主题.
问题是某些控件允许编辑属性,但是会遗漏其他控件.
这是我尝试过的:
Component TabStop FocusRect Text V.Align Borderless Color
----------------------------------------------------------------------------
TButton V V V - -
TSpeedButton V V V - -
TLabel - - V V V
TPanel V - V V V
TStaticText V - - V V
TcxButton V V V - V
TcxLabel - - V V V
----------------------------------------------------------------------------
* Text V.Align - vertical text alignment to center
* Borderless - no borders in default/unfocused state
** Color - ability to set face color …Run Code Online (Sandbox Code Playgroud)