0

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

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.

“鼠标点击后删除棒,此操作无效,请帮助”

stk color: Color transparent.
stk delete.

“”

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

1 回答 1

2

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

self handlesMouseDown: evt.

如果你想接收 mouseDown: 消息,那应该返回 true。在工作空间中,那个自我是不存在的。结果从未使用过。只需删除它。生成的代码将类似于

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.
于 2015-09-04T23:12:25.250 回答