colorPicker.dropTarget About

Hello. I want to use the code below to select a color on the stage or within any container using a colorPicker. I want the colorPicker.dropTarget to be null when selecting. However, even if the selection is made, it still doesn't become null. I can't do anything else.


    renkKopyala.on("mousedown",function(){

        colorPicker.dropperTarget=bitmapDataCont
        bitmapDataCont.addEventListener("pressup",dropperKaldirildi)

        
    })

    function dropperKaldirildi(){

      
          colorPicker.dropperTarget=null
            
      

    }

I do not see a dropperTarget property... so perhaps it can't be set after initialized. You can update the existing dropperTarget with updateDropperTarget()

updateDropperTarget() - with the "spectrum" setting, a cached view of the dropperTarger is shown to pick the color from. Using updateDropperTarget() will update this cached view - it is processor intensive so beware

If this is all you need, let us know. If you really need to switch the dropperTarget, you can remake the the colorPicker or if that does not work for you, let us know and we can see if we can add a dropperTarget property and patch 018.

How do I edit my existing code above? Can you help me?

What I want is this: I want to select the color the user previously painted on any object in the scene. I want to use dropperTarget for this. DropperTarget works; it makes the selection. However, I don't want the round selection tool after the selection.

Perhaps, if you want them to pick a color, they press an "Add Color" button that shows the ColorPicker. Then they pick a color and close the ColorPicker when happy (or automatically close it after picking). Then they carry on coloring and if they want to pick another color, they press the "Add Color" button and the ColorPicker and the selector will come back.

After making a selection, the dropperTarget is still active. I want it to be disabled upon the first selection.

The target disables when you close the ColorPicker. Try opening it when you press the choose color and close it when you change the color.

If you really want the Picker there all the time, perhaps swap it with another Picker without the dropperTarget and set a mousedown on it to swap to the picker with the dropTarget.

1 Like

Using two different colorPickers worked. Thank you very much.

1 Like