Skip to content

Problems using ColorPicker and CodeEditor at the same time #13

Open

Description

@SNQ-2001

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

Activity

  1. helje5 commented on Apr 21, 2022

    @helje5
    Member

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

  2. helje5 commented on Apr 21, 2022

    @helje5
    Member

    Though two color pickers work alongside.

  3. helje5 commented on Apr 21, 2022

    @helje5
    Member

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

  4. SNQ-2001 commented on Apr 21, 2022

    @SNQ-2001
    ContributorAuthor

    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!!!

  5. helje5 commented on Apr 21, 2022

    @helje5
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions