Omnibar

Swift 5.7 Version Platform Carthage compatible

一个支持键入字符串自动补全的搜索框。

正在寻找 RxSwift 兼容性? Reactive Extensions (RxSwift) 在 v0.21 版本后已迁移至 https://github.com/CleanCocoa/RxOmnibar

概述

旨在满足以下需求

  1. 快速过滤搜索结果;
  2. 在 Omnibar 内部通过方向键更改结果选择;
  3. 在文本框本身中提供搜索词的自动补全。

例如,如果您键入“aard”,Omnibar 将在示例应用程序中建议术语“aardvark”

基于委托的方法

显示值

调用 display(content: OmnibarContent) 来更改 Omnibar 的内容并影响选择。您也可以使用 stringValue 属性来更改文本并将插入点放在末尾,就像常规的 NSTextField 一样。

public enum OmnibarContent {

    /// Empties the Omnibar.
    case empty

    /// Display `text` inside the Omnibar and select it all (like ⌘A) for
    /// quick overwriting.
    case selection(text: String)

    /// Display `text` inside the Omnibar and put the insertion point
    /// at the end.
    case prefix(text: String)

    /// Display `text`, followed by `appendix`, putting the insertion point
    /// before `appendix` and selecting it so it can be overwritten.
    case suggestion(text: String, appendix: String)
}

响应事件

设置 delegate 以接收更改通知。OmnibarDelegate 协议提供以下函数签名

ChangeMethod 可以是 .deletion(删除)、.insertion(插入)或 .appending(附加),以传达用户所做的操作,以便您可以对所有情况做出不同的反应。

OmnibarContentChange 要么是旧内容的 .replacement(替换),要么是最后一次建议的 .continuation(延续),如果存在任何建议;.continuation 就像一个自我建议的 OmnibarContent.suggestion,等待批准。

enum OmnibarContentChange {
    case replacement(text: String)
    case continuation(text: String, remainingAppendix: String)
}

归属和贡献

英语开放词汇列表 (EOWL) v1.1.2

示例应用程序使用一个包含 12000 多个英语单词的列表来显示和过滤。

“英语开放词汇列表” (EOWL) 由 Ken Loge 开发,但几乎完全源自 J Ross Beresford 的 “UK Advanced Cryptics Dictionary” (UKACD) 1.6 版。

许可

Omnibar

版权所有 (c) 2017 Christian Tietze。在 MIT 许可证下分发。

英语开放词汇列表 (EOWL)

版权所有 © J Ross Beresford 1993-1999。保留所有权利。 对本出版物的使用有以下限制:如果在软件包中使用英国高级密码词典或以任何形式重新分发,则必须醒目地显示版权声明,并且必须逐字包含本文档的文本。