focus 相关问题

Focus表示当前选择用于接收输入的图形用户界面的组件。

如何从 WinForms 中的 TextBox 中移除焦点?

我需要从几个文本框中删除焦点。我尝试使用: textBox1.Focused = false; 它的 ReadOnly 属性值为 true。 然后我尝试将焦点设置在表单上,以便将其删除......

回答 21 投票 0

如何允许同时关注两个组件,TextField 和 Popover

我有一个呈现在文本字段组件下方的弹出框组件。用例是当用户在文本字段中键入特殊键(例如:)时切换菜单。然后用户可以单击

回答 1 投票 0

如何检测图像是否失焦?

有时我们的光学检测系统会失焦,从而导致无意义的测量。我的任务是开发一种“失焦”探测器,用于驱动...

回答 3 投票 0

如何防止新的WPF表单窃取焦点?

我编写了一个简单的 MSN 风格的程序,它将使用 WCF 发送和检索消息。主窗体包含一个文本框,用于输入要发送的消息。应用程序在后台进行民意调查...

回答 4 投票 0

使用 QtQuick.Controls 1.4,当鼠标移到 ComboBox 或 SpinBox Item 上时如何防止焦点改变?

我使用 ListView,在该 ListView 的每个项目内,我有一个 ComboBox 或 SpinBox。 我的问题是,当我想滚动 ListView 时,如果我的鼠标移到 ComboBox 或 SpinBox 上,焦点...

回答 1 投票 0

我无法找到 e.preventDefault() 在 trapFocus 函数中做什么

我明白这个函数的作用,但我真的不知道 e.preventDefault() 是做什么的。我知道这会阻止 keydown 事件的默认行为,但我真的不知道哪种行为......

回答 1 投票 0

C# 停止按钮获得点击焦点

我有几个按钮,单击时我不希望它们获得焦点,也不希望空格键再次“按下”它们。 我想要与 Windows 计算器中的按钮相同的功能。 去...

回答 3 投票 0

FocusState Textfield 在工具栏 ToolbarItem 中不起作用

让我解释一下,我有一个带有 SearchBarView 的父视图,我正在传递这样的焦点状态绑定。 SearchBarView(searchText:$object.searchQuery, 搜索: $object.searching, 聚焦:

回答 1 投票 0

Jetpack Compose BasicTextField 占位符阻止在单击时获得焦点

我使用 Jetpack Compose BasicTextField 并使用文本组件设置占位符,如下所示: 当我单击占位符文本时,文本字段不会获得焦点。 这是 Compos 上的错误吗...

回答 2 投票 0

找不到 CSS 选择器来设置 Shadow DOM 委托焦点的样式

编辑1+ 好吧,抱歉,徒劳无功。这似乎是一个直接的 CSS 问题。在光 DOM 中:- #disTick::部分(内藤){ 盒子阴影:插入 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0p...

回答 1 投票 0

C# WPF ListView SelectedItem 在失去焦点时保持值

问题:当我尝试按下与 ListView 面板不同的另一个面板上的按钮时,失去 ListView 项目焦点并因此重置 SelectedItem 属性。我需要保持专注(可选...

回答 1 投票 0

ng-select 的焦点不起作用 Angular 5

我正在尝试在 Angular 5 中使用焦点进行 ng-select,但它不起作用 我正在使用 ng2-select 如何在 Angular 5 中使用焦点进行 ng-select ? 我正在尝试在 Angular 5 中使用焦点进行 ng-select,但它不起作用 我正在使用 ng2-select 如何在 Angular 5 中使用焦点进行 ng-select ? <label class="input"> <input (blur)="goTo()" type="text"> </label> <label class="select" > <div *ngIf="items.length > 0" > <ng-select #select [items]="items"> </ng-select> </div> </label> @ViewChild('select') myElement: ElementRef; goTo(){ this.myElement.element.nativeElement.focus(); } 这对我来说效果很好, @ViewChild('ngSelect') ngSelect: NgSelectComponent; ngAfterViewInit() { if (this.autofocus) { setTimeout(() => { this.ngSelect.focus(); }); } } 参考https://github.com/ng-select/ng-select/issues/762 改变这个 goTo(){ this.myElement.element.nativeElement.focus(); } 对此, import { ChangeDetectorRef } from '@angular/core'; constructor (private cRef: ChangeDetectorRef) {} // import 'SelectComponent' from your library for 'ng2-select' goTo(){ let el = null; if (this.items.length > 0) { this.cRef.detectChanges(); el = (this.myElement.nativeElement as SelectComponent).element.nativeElement.querySelector('div.ui-select-container > input'); if (el) { el.focus(); } } } 您可能需要检查该元素是否已定义(或者您是否需要其中额外的“nativeElement”,但我基本上重用了here中的逻辑。 请注意,如果库更新以重命名这些类或修改模板,这可能不是一个稳定的修复。 希望有帮助。 一个简单的方法,你也可以这样做。 <label class="input"> <input (blur)="goTo(select)" type="text"> </label> <label class="select"> <div *ngIf="items.length > 0"> <ng-select #select [items]="items"> </ng-select> </div> </label> 并在 Typescript 文件中。 goTo(select){ select.focus(); } 快速回复,在此解决方案中,记录每个选择元素以供将来使用(在本例中为模糊)。这需要根据您的情况进行调整。 import { Component, OnInit } from '@angular/core'; import { ViewChildren, QueryList } from '@angular/core'; @Component({ selector: 'app-editor', templateUrl: './editor.component.html', styleUrls: ['./editor.component.css'] }) export class EditorComponent implements AfterViewInit { // Viewchildren // https://netbasal.com/understanding-viewchildren-contentchildren-and-querylist-in-angular-896b0c689f6e myindex:number; @ViewChildren("select") inputs: QueryList<any> constructor() { this.myindex=0 } // You will have to setup some input parameters in this function in order to switch to the right "select", (you have control) private goTo() { // focus next input field if (this.myindex +1 < this.inputs.toArray().length) { this.inputs.toArray()[this.myindex +1].nativeElement.focus(); this.myindex = this.myindex + 1; } else { this.inputs.toArray()[0].nativeElement.focus(); this.myindex = 0; } } private processChildren(): void { console.log('Processing children. Their count:', this.inputs.toArray().length) } ngAfterViewInit() { console.log("AfterViewInit"); console.log(this.inputs); this.inputs.forEach(input => console.log(input)); // susbcribe to inputs changes, each time an element is added (very optional feature ...) this.inputs.changes.subscribe(_ => this.processChildren() // subsequent calls to processChildren ); } } 将“#id”添加到 ngSelect 元素 <ng-select #id></ng-select> 然后添加: @ViewChild('id') Ele: NgSelectComponent; 在 component.ts 文件中 然后使用:this.Ele.focus进行对焦,它将对焦

回答 5 投票 0

如何清除视图中所有可选元素的焦点?

我的问题很简单。如何清除视图中可能具有焦点的所有元素的焦点(例如 EditText -或 - TextView,其 textIsSelectable="true" 并且在发生...时在其中选择文本

回答 4 投票 0

显示抽屉式导航栏时,清晰地关注内容

在具有导航抽屉的 Android 活动中清除焦点的最佳方法是什么。 问题是,当用户选择了文本框时,如果您打开导航抽屉......

回答 2 投票 0

Flutter中如何将焦点转移到下一个TextField?

我是 Flutter 新手。 我正在使用以下小部件构建具有多个文本输入的表单:Form、TextFormField。出现的键盘不显示“下一个”(这应该将焦点转移到下一个

回答 12 投票 0

当子元素只有:focus-visible时,如何获取父元素:focus-within?

当子元素只有焦点可见时,如何让父元素获得焦点? 我希望父母在通过键盘聚焦孩子时获得轮廓。 但这段代码总是有焦点(大纲)...

回答 1 投票 0

在 Vue 3 中单击按钮后如何将焦点保持在输入上而不闪烁?

脚本 const amountRef = ref(null); 常量数量 = ref(0.1); const insertSuggestion = (e, 值) => { e.preventDefault(); e.stopPropagation(); 金额.价值 = 价值; amountRef.value.focus...

回答 3 投票 0

React Native 输入字段在输入字符后失去焦点

每次我在任何输入字段中输入字符时,它都会失去焦点,并且除非我单击返回输入字段,否则我无法继续输入。 这是我的登录表单。我检查了一下以确保

回答 1 投票 0

如何以编程方式设置 Compose Accessibility Talkback 的焦点

我想在第二个屏幕返回后按单击聚焦原始视图。例如,当我单击法律按钮时,应用程序将导航到第二主屏幕。当第二个主屏幕...

回答 1 投票 0

在 WPF XAML 中将焦点设置在 TextBox 上

尽管此论坛和其他论坛上有一些帖子,但我找不到告诉我如何将焦点设置在文本框上的内容。 我有一个带有许多标签和文本框的用户控件。加载表单后,我...

回答 10 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.