Skip to content
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

Problems using ColorPicker and CodeEditor at the same time #13

Open
SNQ-2001 opened this issue Apr 21, 2022 · 5 comments
Open

Problems using ColorPicker and CodeEditor at the same time #13

SNQ-2001 opened this issue Apr 21, 2022 · 5 comments

Comments

@SNQ-2001
Copy link
Contributor

SNQ-2001 commented Apr 21, 2022

I found a new issue regarding the relationship between ColorPicker and CodeEditor

(1) Start ColorPicker
(2) Double-tap Text in CodeEditor

↓ Result ↓

The color of the Text is reflected in the ColorPicker

import SwiftUI
import CodeEditor

struct ContentView: View {
    @State var source: String = """
import SwiftUI
import CodeEditor

struct ContentView: View {
    @State var source: String = ""
    @State var color: Color = Color.white
    var body: some View {
        HStack {
            ColorPicker("", selection: $color)
            CodeEditor(source: $source)
        }
    }
}
"""
    @State var color: Color = Color.white
    var body: some View {
        ZStack {
            color
                .edgesIgnoringSafeArea(.all)
            HStack {
                ColorPicker("ColorPicker", selection: $color)
                CodeEditor(source: $source, language: .swift, theme: .pojoaque)
            }
        }
    }
}
2022-04-22.0.14.52.mp4
@helje5
Copy link
Member

helje5 commented Apr 21, 2022

I still think that this is likely a bug in SwiftUI itself, not in the CodeEditor.

@helje5
Copy link
Member

helje5 commented Apr 21, 2022

Though two color pickers work alongside.

@helje5
Copy link
Member

helje5 commented Apr 21, 2022

I wonder whether the behaviour is actually intentional. I.e. the NSColorWell is active, and you pick the color in some text field 🤔

@SNQ-2001
Copy link
Contributor Author

If it's a SwiftUI bug, there's nothing we can do about it😭
We can only hope for the development of SwiftUI

CodeEditor is a great OSS!
Thanks for creating it!!!

@helje5
Copy link
Member

helje5 commented Apr 21, 2022

I'm not quite sure yet, maybe it isn't even a bug. I have the feeling the colorwell should resign being active (and stop tracking the NSColorPanel) if the NSTextView becomes first responder again.

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

No branches or pull requests

2 participants