Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: KeyboardPickerBarButtonItem class
---

## Summary

Returns a UIBarButtonItem that will display the keyboard picker when tapped.

## Syntax

``` swift
KeyboardPickerBarButtonItem(presentingVC: UIViewController)
```

### Parameters

`presentingVC`
: View controller to handle the keyboard picker modes.

## Description

Opens a view for the user to switch keyboards or download new keyboards.

Since the keyboard picker is modal, a UIViewController must be supplied to display it. The button has default images for normal and landscape orientation, and can overridden with other images or a title.

## Examples

### Example: Using `KeyboardPickerBarButtonItem()`

The following script illustrates the use of `KeyboardPickerBarButtonItem()`:

``` swift
let kbBarButton = KeyboardPickerBarButtonItem(presentingVC: self)
```

## See also

- [`KeyboardPickerButton()`](../KeyboardPickerButton/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: KeyboardPickerButton class
---

## Summary

The **KeyboardPickerButton** class provides a button that triggers the language picker menu

## Syntax

``` swift
KeyboardPickerButton.methodName()
```

## Description

Opens a view for the user to switch keyboards or download new keyboards.

## Methods

[`setTitle()`](setTitle)
: clear images if the developer sets a title

## Examples

### Example: Using `KeyboardPickerButton()`

The following script illustrates the use of `KeyboardPickerButton()`:

``` swift
let kbButton = KeyboardPickerButton(presentingVC: self)
```

## See also

- [`KeyboardPickerBarButtonItem()`](../KeyboardPickerBarButtonItem/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: KeyboardPickerButton.setTitle()
---

## Summary

The **`setTitle()`** method sets the title of the keyboard picker button.

## Syntax

``` swift
KeyboardPickerButton.setTitle(title: String, state: UIControlState)
```

### Parameters

`title`
: Title for the button.

`state`
: State of the button

## Description

Clear images if the developer sets a title.

## Examples

### Example: Using `setTitle()`

The following script illustrates the use of `setTitle()`:

``` swift
let kbButton = KeyboardPickerButton(presentingVC: self)
kbButton.setTitle(item.title, for: .normal)
```
81 changes: 81 additions & 0 deletions developer/engine/iphone-and-ipad/20.0/KeymanPackage/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: KeymanPackage class
---

## Summary

The **KeymanPackage** class and its subclasses represent Keyman package
files and their contents.

## Syntax

``` swift
KeymanPackage.methodName()
```

## Description

The KeymanPackage is the base class used to represent various types of
Keyman packages within the Keyman Engine and their contents. As an
abstract class, it serves as a "type erasure" for its subclasses
`KeyboardKeymanPackage` and `LexicalModelKeymanPackage`, both of which
offer richer typing for certain fields and methods.

## Fields

`key:` [`KeymanPackage.Key`](key)
: Returns a unique identifier for the package, usable in package-search operations.

`languages: [Language]`
: An array of languages supported by the keyboards or lexical models contained by the package.

The most relevant fields for `Language` type are the `name: String` and `id: String` fields. (The other fields are mostly 'legacy'.)

`name: String`
: The user-friendly name of the package.

`resourceType: LanguageResourceType`
: An enum representing the type of LanguageResource contained within the package.

May be either `.keyboard` (for a `KeyboardKeymanPackage`) or `.lexicalModel` (for a `LexicalModelKeymanPackage`).

`sourceFolder: URL`
: The base folder for the package's extracted contents.

---
**Note:** For packages opened with [`ResourceFileManager.shared.prepareKMPInstall`](../ResourceFileManager/prepareKMPInstall), this may be a temporary location!

---

Stability is not guaranteed if you write to any contents of the folder or its subfolders, but read operations are permitted.

`version: Version`
: The package's version.

## Methods

[`installableResourceSets -> [[AnyLanguageResource]]`](installableResourceSets)` `
: Returns a list of all resources & language pairings supported by this package.

[`installableResources(forLanguage: String) -> [AnyLanguageResource]`](installableResources)` `
: A language-filtered version of the method above.

[`pageURL(for: KeymanPackagePage) -> URL?`](pageURL)
: Provides a link to known .html files contained by the package.

Supported pages: `.readme`, `.welcome`, `.custom(bundledPath: String)`, the latter of which may target arbitrary locations within the package.

## History

Added in Keyman Engine for iPhone and iPad 14.0.

## See Also

- [`PackageWebViewController`](../PackageWebViewController)
: Used to display web pages contained within a package.

- [`KeyboardKeymanPackage`](../TypedKeymanPackage)
: Represents packages containing keyboards.

- [`LexicalModelKeymanPackage`](../TypedKeymanPackage)
: Represents packages containing lexical models.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: .installableResourceSets()
---

## Summary

The **`KeymanPackage.installableResourceSets`** field enumerates all resources and language pairings supported by the current package.

## Syntax

``` swift
KeymanPackage.installableResourceSets: [[ AnyLanguageResource ]]
```

### Value

The two dimensional array may be interpreted as follows:

``` swift
package.installableResourceSets[resourceIndex][languageIndex]
```

`resourceIndex`
: Some legacy keyboard packages may support multiple keyboards. This index enumerates the unique keyboards (or lexical models) contained within the package.

`languageIndex`
: Some resources support multiple languages. For example, Keyman's default keyboard - `sil_euro_latin` There will be one entry for each language supported by the resource.

The indexed value
: `AnyLanguageResource` is a Swift "type erasure" that may represent either an `InstallableKeyboard` or an `InstallableLexicalModel`, each of which enumerates the metadata needed for the Keyman engine to properly load and use the resource.

These objects typically include data about the needed fonts, underlying language codes, and resource identifiers.

## History

Added in Keyman Engine for iPhone and iPad 14.0.

## See also

- [`KeyboardKeymanPackage.installables: [[ InstallableKeyboard ]]`](../TypedKeymanPackage/installables)
: The equivalent field for keyboard packages.

- [`LexicalModelKeymanPackage.installables: [[ InstallableLexicalModel ]]`](../TypedKeymanPackage/installables)` `
: The equivalent field for lexical model packages.

- [`installableResources(forLanguage: String): [ AnyLanguageResource ]`](installableResources)
: Provides the same functionality as this field, but filtered to a specific language code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: .installableResources(forLanguage:)
---

## Summary

The **`KeymanPackage.installableResources(forLanguage: String)`** method
enumerates all resources and language pairings supported by the current
package for the specified language code.

## Syntax

``` swift
KeymanPackage.installableResources(forLanguage: String) -> [ AnyLanguageResource ]
```

### Parameter

`forLanguage: String`
: A BCP-47 language code.

### Value

An array of `InstallableKeyboard` (for a `KeyboardKeymanPackage`) or `InstallableLexicalModel` (for a `LexicalModelKeymanPackage`) instances.

For most packages, there will only be a single entry in this array.
However, note that multi-keyboard packages may support multiple
keyboards for the same target language.

## History

Added in Keyman Engine for iPhone and iPad 14.0.

## See also

- [`installableResourceSets: [[ AnyLanguageResource ]]`](installableResourceSets)
: Returns a list of all resources & language pairings supported by this package.

- [`TypedKeymanPackage.installables(forLanguage: String): [ TypedLanguageResource ]`](../TypedKeymanPackage/installables_forLanguage)
: Provides the same functionality as this method for `TypedKeymanPackage` and its subclasses, taking advantage of the class's generic specification to return a more strongly-typed array.
32 changes: 32 additions & 0 deletions developer/engine/iphone-and-ipad/20.0/KeymanPackage/key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: KeymanPackage.Key class
---

## Summary

The **KeymanPackage.Key** class serves as a unique identifier for packages.

## Syntax

``` swift
KeymanPackage.Key.field
```

## Description

The KeymanPackage.Key class is used within the KeymanEngine by installed resources when there is a need to find and/or use their source packages. Such operations only succeed with installed packages.

## Fields

`id: String`
: The package's id string.

Generally speaking, this is the filename for the package file once the file extension (`.kmp` for keyboard packages, `.model.kmp` for lexical model packages) has been removed.

`type: LanguageResourceType`
: An enum representing resource types supported by the KeymanEngine. May be either `.keyboard` (for a `KeyboardKeymanPackage`) or `.lexicalModel` (for a `LexicalModelKeymanPackage`).

## History

Added in Keyman Engine for iPhone and iPad 14.0.

35 changes: 35 additions & 0 deletions developer/engine/iphone-and-ipad/20.0/KeymanPackage/pageURL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: .pageURL(for:)
---

## Summary

The **`KeymanPackage.pageURL(for: KeymanPackagePage)`** method provides links to web pages contained within a package.

## Syntax

``` swift
KeymanPackage.pageURL(for: KeymanPackagePage) -> URL?
```

### Parameters

`for: KeymanPackagePage`
: An enum representing the type of page to retrieve.

Supported pages: `.readme`, `.welcome`, `.custom(bundledPath: String)`, the latter of which may target arbitrary locations within the package.

May return `nil` if the corresponding file does not exist.

### Value

A `URL` that may be used to display the page within a `WKWebView` or similar module.

## History

Added in Keyman Engine for iPhone and iPad 14.0.

## See also

- [`PackageWebViewController`](../PackageWebViewController)
: Used to display web pages contained within a package.
Loading
Loading