我有一个窗口,我 .show() 似乎无法告诉我它是否聚焦。
如果窗口中有文本框,则 Me.IsFocused 始终为 false。即使您单击文本框并最小化窗口,textbox.IsFocused 也是 True。
有没有办法在不使用 Windows API 函数的情况下确定窗口是最小化还是在另一个窗口后面?
谢谢!
我为创建帐户活动设计了一个布局。
当一个人EditText失去焦点时,我会对输入进行一些检查,如果有什么不对的地方,我想重新集中注意力EditText。
我已经看到了一些关于此的问题,但它对我不起作用(或者我做错了什么)。
当我触摸触发 requestFocus() 的不同 EditText 时,焦点仍停留在当前焦点上EditText,另一个焦点图标显示在EditText请求焦点中。
请帮忙
这是我的布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.cellap.tq"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="@drawable/create_account_background" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginTop="70dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp">
<TextView
android:id="@+id/userTextView"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="#F4DFA7"
android:layout_marginRight="5dp"
android:text="Username"
android:gravity="right"
android:layout_gravity="center_vertical"/>
<EditText
android:id="@+id/userEditText"
android:inputType="text|textEmailAddress"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:maxLength="64"
android:background="@drawable/edit_text"
android:layout_gravity="center_vertical|right"
android:textColor="@android:color/white">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp">
<TextView
android:id="@+id/passTextView"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#F4DFA7"
android:layout_marginRight="5dp"
android:gravity="right"
android:text="Password"/>
<EditText
android:id="@+id/passEditText"
android:layout_width="fill_parent" …Run Code Online (Sandbox Code Playgroud) 正如主题中所述,如何使 JTextField 失去焦点?
就像是:
jtf.setFocus(false)
情况:
我想要做的是在单击电子表格中的类似按钮的图像时,在与所选单元格(不区分大小写)匹配的任何工作表中查找并设置焦点到下一个单元格。有点像 MS Word 可以为您创建的自定义索引。
我的方法是: - 将所选单元格的值设置为变量(成功) - 找到与该变量匹配的第一个单元格(不是所选单元格)(没有成功) - 将找到的单元格的值设置为变量 2(没有成功) - 设置电子表格的焦点到变量2(没有成功)
function FindSetFocus()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var activecell = sheet.getActiveCell();
var valueactivecell = activecell.getValue();
//here comes the code :)
}
Run Code Online (Sandbox Code Playgroud)
我在以下主题中找到了这个片段,但是我在设置输入和处理输出时遇到了一些问题:如何搜索 Google 电子表格?
我想我可以用“valueactivecell”替换“value”,但我不知道如何设置范围来搜索电子表格中的所有工作表。另外,我希望输出是我可以使用类似 'ss.setActiveSheet(sheet).setActiveSelection("D5");' 设置焦点的东西
/**
* Finds a value within a given range.
* @param value The value to find.
* @param range The range to search in.
* @return A …Run Code Online (Sandbox Code Playgroud) 我已经尝试了平常但它不起作用:
multiEdit.requestFocus();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(multiEdit, InputMethodManager.SHOW_IMPLICIT);
Run Code Online (Sandbox Code Playgroud)
注意我的getActivity().那是因为我MultiAutoCompleteTextView在DialogFragment中使用.片段在里面onCreateView.
keyboard android focus autocompletetextview android-softkeyboard
我希望默认情况下将光标显示在JTextField"框"中.目前,我必须将光标放在框中才会出现.这是代码.
class XYZ extends JFrame implements ActionListener {
JTextField box = new JTextField();
JButton again = new JButton("Restart");
JButton ext = new JButton("Exit");
XYZ() {
box.addActionListener(this);
again.addActionListener(this);
ext.addActionListener(this);
box.setPreferredSize(new Dimension(20,20));
box.setHorizontalAlignment(JTextField.CENTER)
JPanel s3 = new JPanel(new BorderLayout()); //This holds the 3 panels below
JPanel restart = new JPanel(new BorderLayout()); //this holds a button
JPanel leave = new JPanel(new BorderLayout()); //also holds a button
//The following holds a JLabel and the textfield
JPanel middle = new JPanel(new FlowLayout(FlowLayout.CENTER,20,0));
JLabel j2 = …Run Code Online (Sandbox Code Playgroud) 我正在尝试让计时器每 250 毫秒检查一次特定程序是否处于焦点状态,但我不知道如何...
当前代码:
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Hearthstone_Test
{
public partial class Main : Form
{
private void timer1_Tick(object sender, EventArgs e)
{
var activatedHandle = GetForegroundWindow();
if (GetForegroundWindow() == Process.GetProcessesByName("Hearthstone"));
{
Console.WriteLine("Not Focused"); // No window is currently activated
}
else
{
Console.WriteLine("Focused");
}
var procId = Process.GetCurrentProcess().Id;
int activeProcId;
GetWindowThreadProcessId(activatedHandle, out activeProcId);
}
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern int …Run Code Online (Sandbox Code Playgroud) 我的 WPF 表单中有一个 Listview 和其他控件。当我在控件之间切换并聚焦 ListView 时,会自动聚焦 ListView 项目,而不是 ListView 本身,它允许使用键盘在项目之间移动。
当用户单击 ListView 中的空白区域时,我想要相同的行为。所以我为ListView创建了一个Click事件,但是不知道执行哪个代码。我试过了;
ListView.Focus();
Keyboard.Focus(ListView);
Run Code Online (Sandbox Code Playgroud)
但是 ListView 本身总是聚焦的,我猜这是有道理的.. 将 ListView 设置为 focusable = false 会完全禁用聚焦,包括项目和使用 Tab 键聚焦也不再起作用。
如何在 OnClick 事件中重新创建 Tab 焦点行为?
我正在使用 React Native 开发一个应用程序。在那里,我想View在按下按钮时滚动到 a 。我试过这样的事情。
render() {
return(
<View ref={field => this.myView = field} >
//something inside the view
</View>
)
}
Run Code Online (Sandbox Code Playgroud)
然后,尝试
this.myView.focus()
Run Code Online (Sandbox Code Playgroud)
但是,它不起作用。
我想得到如下 GIF 演示所示的结果。这该怎么做?
我有自定义输入组件vue js,在这个组件中我有输入和两个按钮。当输入松散焦点时,我想专注于下一个输入,但现在它专注于那些按钮。最后我应该按三下 tab 键来专注于下一个输入。
是否有任何 html 属性可以禁用对某些元素的关注?或者有一种javascript方式?
focus ×10
java ×3
android ×2
c# ×2
javascript ×2
jtextfield ×2
swing ×2
window ×2
wpf ×2
cursor ×1
find ×1
html ×1
keyboard ×1
listview ×1
listviewitem ×1
react-native ×1
search ×1
view ×1
vue.js ×1
xml ×1