标签: button

为什么在 displayModeButtonItem 触发 splitViewController 折叠时不调用 viewWillTransitionToSize...?

我有一个 UISplitViewController,它的辅助(详细)VC 是一个 UICollectionViewController。我希望集合的单元格根据集合视图的大小和方面的变化来调整大小。我通过覆盖 UIContentContainer 协议方法触发此调整大小:

// MARK: - UIContentContainer protocol methods

override
func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
{
    setFlowLayoutItemSizeForViewSize(size)
    collectionViewLayout.invalidateLayout()
}
Run Code Online (Sandbox Code Playgroud)

当设备旋转时,这就是我想要的方式调用和工作;但是当 splitViewController?.displayModeButtonItem() 提供的按钮被按下以显示或折叠主(主)视图控制器时,不会调用此方法。由于折叠必然会更改辅助(详细信息)视图的大小,因此我认为应该在触发时调用 viewWillTransitionToSize... 方法。

所以,两个问题:

1) 实际上是否应该在按下 displayModeButtonItem 时调用 viewWillTransitionToSize... 方法?如果是这样,我似乎发现了一个错误。

2)如果我看到的实际上是正确的行为,任何人都可以建议我的辅助(详细)控制器“知道”什么时候按下 displayModeButtonItem 或者它的大小何时因该按钮而改变被压?

谢谢!

卡尔

button uisplitviewcontroller ios displaymode viewwilltransitiontosize

6
推荐指数
1
解决办法
3737
查看次数

增加 Android 按钮中的触摸倾斜

我们有一个 Android 应用程序,旨在安装在在崎岖地形中运行的车辆的仪表板上,所以一切都非常不稳定。我们发现在这种情况下在屏幕上点击一下是很困难的,因为点击通常被解释为小的拖拽。

我需要的是在手指出现之前有一点摆动的触摸事件被解释为点击,而不是拖动。我一直在阅读 Android 中“touch slop”的工作方式,我可以看到他们已经考虑到了这一点。我真正需要了解的是如何为 Androidbutton小部件的子类增加“触摸倾斜” 。

这可能只用几行代码吗?还是我需要自己实现onInterceptTouchEvent和“onTouchEvent”?如果是后者,谁能给我一些关于如何工作的指导?

android button touch-event

6
推荐指数
1
解决办法
1737
查看次数

Python Gtk3 控制按钮大小

按钮大小应该通过在 VBox 中打包 HBox 来控制,但我的两个按钮仍然具有取决于文本的大小:

    first=Gtk.VBox()
    second=Gtk.HBox()
    third=Gtk.VBox()
    fourth=Gtk.HBox()
    but1=Gtk.Button(label="any title")
    first.pack_start(second,False,False,0)
    third.pack_start(fourth,False,False,0)        
    first.pack_start(but1,False,False,0)
    self.data_wp="title of label"
    self.label_data=Gtk.Label(label=self.data_wp)
    Gtk.Widget.set_size_request(but1,85,15)
    but2=Gtk.Button(label=self.data_wp)
    Gtk.Container.add(but2,self.label_data)
    Gtk.Widget.set_size_request(but2,85,15)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我从标签添加按钮标题,但这应该不是问题,我尝试直接在按钮上设置标题 - 没有任何改变。我尝试只使用一组 VBox,HBox,但也没有效果。

python size button gtk3

6
推荐指数
1
解决办法
4800
查看次数

如何从“ipywidgets”更改用“interact_manual”创建的按钮标签?以及如何更改该按钮的大小和颜色?

如何从“ipywidgets”更改用“interact_manual”创建的按钮标签?以及如何更改该按钮的大小和颜色?

这是我写的

from ipywidgets import interact,interact_manual
def HDI_vs_CrimeRate():
    #do some thing here
interact_manual(HDI_vs_CrimeRate)
Run Code Online (Sandbox Code Playgroud)

这是按钮的样子: 1 感谢您的帮助

python button jupyter-notebook ipywidgets

6
推荐指数
2
解决办法
3775
查看次数

在 Unity 中更改按钮的文本

我试图在 Unity 中打开场景时更改 Button 的文本。我尝试了不同的方法来更改 Button 的文本。

这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class script : MonoBehaviour {

    public Button b1;
    public TMP_Text b1text;


    void Start()
    {
        GameObject b1object = (GameObject)Instantiate(b1);
        b1text = b1object.GetComponentInChildren<TMP_Text>(true);
        btnValue();
    }

    public void btnValue()
    {
        b1text.text = "sdfa";
    }

}
Run Code Online (Sandbox Code Playgroud)

c# button unity-game-engine

6
推荐指数
1
解决办法
1万
查看次数

如何暂停 Jupyter Notebook 小部件,等待用户输入

在我的笔记本中,我有一个循环,我想在其中要求用户二进制“是”或“否”。在这个选择上,算法应该继续。

for i in range(n_total):
    display.clear_output(wait=True)
    waiting_for_scoring = True
    print("True or False?")
    display.display(widgets.HBox((true_button, false_button)))
    a = true_button.on_click(on_true_button)
    a = false_button.on_click(on_false_button)
    while waiting_for_scoring == True:
        #waiting for user input
        pass
Run Code Online (Sandbox Code Playgroud)

在小部件 HBox 创建之后,如何使循环等待,并等待用户输入(单击按钮)以继续回答新值?

这是我对按钮的两个功能:

def on_true_button(x):
    global waiting_for_scoring
    print('NO!!!!')
    y_new = 1
    waiting_for_scoring = False
    return y_new

def on_false_button(x):
    global waiting_for_scoring
    print('YES')
    y_new = 0
    waiting_for_scoring = False
    return y_new
Run Code Online (Sandbox Code Playgroud)

你能帮我停止循环直到用户按下按钮然后使用这个输入吗?先感谢您

python asynchronous button jupyter-notebook ipywidgets

6
推荐指数
1
解决办法
1402
查看次数

Ionic 4 - 平板电脑上的点击与触摸启动(点击/移动配置问题)

我们开发了一个安装在安卓平板电脑上的 POS(销售点)中的 Ionic 4 应用程序。

问题是,<ion-button (click)="doSomething">事件通常无法识别,因为用户站在平板电脑前面,平板电脑非常低并且没有发出干净的点击,但是一个非常小的水平移动,离子似乎将其识别为(触摸)移动。这种情况在廉价的三星 Tab A 和三星 Tab S3 上都经常发生。

该按钮实际上会像触摸一样改变它的颜色,但它不会触发。这不会发生在 android 键盘上,所以键盘上的按钮似乎更能容忍小动作。

我们尝试了很多组合,例如

(click) tappable
tap
(click) (touchmove)
(clik) (tap)
(tap) 
(click) (touchstart)
(touchmove)
(touchstart)
Run Code Online (Sandbox Code Playgroud)

唯一有效的是最后一个。(自然不能在元素列表中使用,因为它会阻止滚动,但我们可以接受)。

现在我认为这是一个有点肮脏的解决方法。有没有更好的解决方案来解决这个问题,比如配置按钮内移动的容差?(事实上​​,只要我的手指停留在按钮区域,我就想识别点击,这就是它在角键盘上的工作方式)。

欢迎任何建议。

顺便说一句:我不记得在 Ionic 3 上有这么严重的问题,但我可能是错的。

click button touchstart angular ionic4

6
推荐指数
1
解决办法
2323
查看次数

暂停 Jupyter Notebook 小部件,等待用户输入

我和 TheInterestedOne在此处提出的问题相同。

我需要为用户创建两个按钮,并建议用户点击循环中的两个按钮之一;以便循环的下一次迭代仅在用户选择之后发生。

我读过这个来源,但我不能让它适用于按钮。我不明白,在使用按钮的情况下,小部件属性如何变化。

from functools import wraps
def yield_for_change(widget, attribute):
    def f(iterator):
        @wraps(iterator)
        def inner():
            i = iterator()
            def next_i(change):
                try:
                    i.send(change.new)
                except StopIteration as e:
                    widget.unobserve(next_i, attribute)
            widget.observe(next_i, attribute) //**button.on_click(on_button_clicked) 
                                                                may be?**
            # start the generator
            next(i)
        return inner
    return f


from ipywidgets import Button
button=Button()


def on_button_clicked():
    print("Button clicked.")


@yield_for_change(button, 'value')
def f():
    for i in range(10):
        print('did work %s'%i)
        x = yield
        button.on_click(on_button_clicked)
Run Code Online (Sandbox Code Playgroud)

python widget button jupyter-notebook ipywidgets

6
推荐指数
2
解决办法
5495
查看次数

我如何防止页面重新加载表单提交角度 7

我不熟悉 Angular。我面临提交按钮的问题。当我点击提交类型的按钮时,它正在重新加载完整的页面。而不是调用我的服务 API。

即使我在表单标签和按钮单击方法中添加了 (keydown.enter)="$event.preventDefault()" ,我也尝试使用 event.preventDefault() 。但没有奏效。

请检查我下面的代码

<form  #createForm="ngForm" class="login-form text-center" (ngSubmit)="Update()" (keydown.enter)="$event.preventDefault()">
       <table cellpadding="5" class="mx-auto">
          <tr>
            <td>
              <label class="white pr-2" for="email" autofocus>Email</label>
            </td>
            <td>
              <input name="email" id="email" type="text" [(ngModel)]="email" required  #name="ngModel"class="d-inline-block w-100" >
            </td>
          </tr>

          <tr>
            <td></td>
            <td class="text-left">

                <button class="d-inline-block text-left lh-100" id="login" type="submit"  [disabled]="!createForm.form.valid">Change Password
                 </button>&nbsp;
                 <button class="float-right lh-100" style="background-color:grey" [routerLink]="'/login'" >Back to Login</button>

             </td>
          </tr>
        </table>
      </form>
Run Code Online (Sandbox Code Playgroud)

这是我的 .ts 代码。按钮更新方法

Update()
  {

   this.userservice.changePassword(this.email).pipe(first())
    .subscribe(
        data => 
        {
            if(!data.message)
            {
              this.errorMsg = data.message;
            }
           else …
Run Code Online (Sandbox Code Playgroud)

submit button reload angular7

6
推荐指数
2
解决办法
9581
查看次数

Material UI IconButton onClick 增加或减少值

我试图执行onClick()一个的材料UI IconButton,这将减小或增加的卡路里每个元素的值在表中,像这样的。我的代码基于Table React 组件页面代码。

在此处输入图片说明

在这种情况下,如果我单击[ - ]按钮,就会递减的值设置为2,并且如果我在[+]按钮点击,将递增的值至4。

import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
import IconButton from '@material-ui/core/IconButton';

//Icons
import AddCircleOutlineRoundedIcon from '@material-ui/icons/AddCircleOutlineRounded';
import RemoveCircleOutlineRoundedIcon from '@material-ui/icons/RemoveCircleOutlineRounded';

/*------------------------- IMPORTS ---------------------------*/

const useStyles …
Run Code Online (Sandbox Code Playgroud)

javascript arrays button reactjs material-ui

6
推荐指数
1
解决办法
2277
查看次数