Skip to content

get cursor position with binding in swiftui view #9

New issue

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

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

Already on GitHub? Sign in to your account

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 pushed 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants