如何从自己的smalltalk中删除HandleMorph的attachMorph

How to remove an attachMorph of HandleMorph in smalltalk from self

我需要你的帮助 我正在使用此代码从特定位置到鼠标位置创建一条线。 单击后我试图删除此行,但我不知道如何 请帮我删除点击后的直播我应该更改什么?

stk:=  (LineMorph from: 100@100 to: 1300@1300 color: Color red width: 2) openInWorld.
handle := HandleMorph new forEachPointDo:  [:newPoint | stk setVertices: {whiteBallinHole position. (newPoint-(10@10)). }.
stk on: #mouseDown send: #value: to:[:evt|
    evt redButtonPressed ifTrue:[  self handlesMouseDown:  evt.

"DELETE THE STICK AFTER MOUSE CLICK THIS DOSNT WORK PLEASE HELP"

stk color: Color transparent.
stk delete.

""

 ].
    ].
    ]. 
    " (self  currentHand attachMorph: handle)."
    " self currentHand addMorph:handle. "
    self currentHand attachMorph:handle. 

代码有点乱。不合适的一件事是

self handlesMouseDown: evt.

如果您想接收 mouseDown: 消息,那应该 return 为真。 在工作区中,那个自我不存在。结果从未使用过。只需删除它。生成的代码类似于

whiteBallinHole := CircleMorph new openInWorld .
stk := (LineMorph 
    from: 100@100 to: 1300@1300 
    color: Color red 
    width: 4) openInWorld.
handle := HandleMorph new forEachPointDo: [ :newPoint | 
stk setVertices: {whiteBallinHole center. (newPoint-(10@10)). }.
stk on: #mouseDown send: #value: to: [:evt|
    evt redButtonPressed ifTrue:[
        stk color: Color transparent.
        stk delete]]].
self currentHand attachMorph: handle.