0
public void dropAccept(final DropTargetEvent event)
{
if (TextTransfer.getInstance().isSupportedType(event.currentDataType))
{
final String d=(String)TextTransfer.getInstance().nativeToJava(event.CurrentDataType);
GC gc = new(text);
//text is the name assigned to the Canvas
text.addPaintListener(new PaintListener()
{
public void paintControl(PaintEvent e)
{
int x= event.x- shell.getBounds().x - text.getBounds().x;
int y=event.y - shell.getBounds().y - text.getBounds().y;
e.gc.drawString(d, x, y);
}
}); } }
이 코드 조각은 텍스트를 캔버스에 끌어 놓기를 구현하는 큰 클래스의 일부입니다. 문제는 캔버스를 놓은 후에 텍스트를 실제로 드롭하는 것이 보이지 않는다는 것입니다.하지만 쉘을 최소화 한 다음 다시 최대화하면됩니다. 누구든지이 코드를 수정하여 즉시 드롭 동작을 표시 할 수있는 방법을 알려주십시오.캔버스의 드래그 앤 드롭 변경 사항은 최소화 된 후에 만 표시됩니다.
하지만 drawstring을 사용하여 캔버스에 텍스트를 설정 했습니까? – Asher
drawString이 페인트 청취자에 있으면,이 청취자는 컨트롤을 다시 그려야하고 SWT에 컨트롤을 다시 그려야한다고 알릴 때까지 호출되지 않습니다. –