[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] Re: [win32] discard SCSpawn?
jk <jk@xxxxxxxx> wrote:
> so drag&drop is a possibility on linux too with swingOSC, happy to know
> about that! so how easily can this be added (i don't realy know swing)
> i much like dragging code in views, makes me feel hip a bit,
to add d'n'd for a swing component is quite easy, you just call myComponent.setTransferHandler( myTransferHandler ), where the transfer handler is a subclass that implements methods such as canImport, importData, createTransferable and exportDone ; not so very different from the methods used in the SC classes.
the main problem is that when imitating the current cocoa classes, you need to be able to add your custom functions on the sclang side (setting the fields canReceiveDragHandler on a SCView for example) ; so to determine whether a component can accept a drag or not is a communication problem : the java component when asked canImport() must always return true, then temporarily save the drag object, send an OSC message to ask sclang canReceiveDrag(), wait for the OSC reply message and if "true", invoke the receiveDrag method on the sclang side.
however i'm sure this can be written in a transparent manner so that the behaviour is very similar to Cocoa. also java allows import/export to the system clipboard for text data. it's a "job" but it can be done.