Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

get cursor position with binding in swiftui view #9

Closed
wants to merge 1 commit into from

Conversation

joehinkle11
Copy link
Contributor

Example usage

struct ContentView: View {
    @State var text = "hello"
    @State var cursorPosition: CGRect? = nil
    
    @ViewBuilder
    var autocompleteOverlay: some View {
        if let cursorPosition = cursorPosition {
            VStack {
                Text("You are typing here")
                Image(systemName: "arrow.down")
                    .foregroundColor(Color.red)
            }.offset(y: -20).position(x: cursorPosition.midX, y: cursorPosition.midY)
        }
    }
    
    var body: some View {
        ZStack {
            VStack {
                Text("firefly test")
                FireflySyntaxEditor(
                    text: $text,
                    cursorPosition: $cursorPosition,
                    language: "swift",
                    theme: "Xcode Light",
                    fontName: "system",
                    didChangeText: { _ in},
                    didChangeSelectedRange: {_,_ in},
                    textViewDidBeginEditing: {_ in}
                ).overlay(autocompleteOverlay)
            }
        }
    }
}

ActuallyTaylor added a commit that referenced this pull request Jul 1, 2021
#9 Now supports macOS
#11 Does not yet support macOS
@ActuallyTaylor
Copy link
Owner

This has been merged into https://github.com/ActuallyZach/Firefly/tree/MacOS

@ActuallyTaylor ActuallyTaylor reopened this Jul 5, 2021
@joehinkle11 joehinkle11 deleted the main branch June 14, 2022 07:25
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants