可可文本字段禁用不会禁用光标更改

发布于 2024-10-25 03:29:45 字数 779 浏览 1 评论 0原文

你好,我有一个盒子,其中一行有 2 个 NSTextFields。

此外,在特定操作上,自定义半透明视图会出现在这 2 个文本字段上。然后进行其他操作时,就会消失。

当这些文本字段被半透明视图覆盖时,我希望它们被禁用,并且当光标进入任何这些文本字段的区域时,我的光标不会改变。然后我希望它们在我的自定义视图消失时启用。

我分别使用以下命令:

[fileNameField setEnabled:NO];
[folderPathField setSelectable:NO];
[folderPathField setEnabled:NO];

[fileNameField setEnabled:YES];
[folderPathField setEnabled:YES];
[folderPathField setSelectable:YES];

来完成此操作。

问题是,一个名为 fileNameField 的更改正确:它变得有点暗,当光标位于文本字段上方时,它既不会被选中,也不会更改我的光标。

但另一个,folderPathField 也被禁用,无法选择文本,但当它进入它的区域时它仍然会改变我的光标。

这两个文本字段之间的唯一区别是:
1. fileNameField 有圆角边框,folderPathField 无边框。
2. fileNameField 的布局设置为“滚动”,folderPathField 的布局设置为“截断”。

有人知道这种行为的原因是什么吗?

Hello I have a box with 2 NSTextFields in one row.

Also on specific action a custom semiopaque view appears over these 2 textfields. And then on other action, disappears.

When these texfields are covered with the semiopaque view I want them to become disabled and my cursor not to change when it comes into the area of any of these textfields. And then I want them to become enabled when my custom view disappears.

I do it using the following commands:

[fileNameField setEnabled:NO];
[folderPathField setSelectable:NO];
[folderPathField setEnabled:NO];

and

[fileNameField setEnabled:YES];
[folderPathField setEnabled:YES];
[folderPathField setSelectable:YES];

respectively.

The problem is that one called fileNameField does change correctly: it becomes a bit dimmed and doesn't either get selected or change my cursor when it is over the textfield.

But another one, folderPathField also becomes disabled, it isn't possible to select the text, but it still changes my cursor when it enters it's area.

The only differences between these two textfields are:
1. fileNameField has rounded border and folderPathField has no border.
2. fileNameField has layout set to "Scrolls" and folderPathField - "Truncates".

Does somebody know what can be the reason for such behaviour?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨轻弹 2024-11-01 03:29:45

需要将其设置为不可编辑

[textfield SetEditable:NO];

You need to set it to not be editable

[textfield SetEditable:NO];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文