Home > Net >  MacOS: Render KeyEquivalent characters
MacOS: Render KeyEquivalent characters

Time:06-21

I would like to render the KeyEquivalent character related to a keyboard shortcut, e.g. KeyEquivalent.upArrow.

According to the SwiftUI code, upArrow is U F700 character.

public struct KeyEquivalent {

    /// Up Arrow (U F700)
    public static let upArrow: KeyEquivalent

But for the code below, it renders a question mark, I assume meaning that it cannot render that.

import SwiftUI

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            Text("KeyEquivalent.upArrow (U F700): \u{F700}") // Same result when trying `"... \(KeyEquivalent.upArrow)"`
                .frame(width: 500, height: 400, alignment: .center)
        }
    }
}

enter image description here

Do you know how to render KeyEquivalent characters correctly?

CodePudding user response:

It is a private space symbol, so not drawable, you have to find own equivalent to represent it visually, like

Text("KeyEquivalent.upArrow (U F700): \u{2191}")

demo

Tested with Xcode 13.4 / iOS 15.5

  • Related