我需要你的帮助 我正在使用此代码创建从特定位置到鼠标位置的线。 点击后我试图删除这一行,但我不知道如何 请点击我应该更改的内容后帮我删除现场直播?
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.
"在鼠标点击此DOSNT工作后删除粘贴请帮助"
stk color: Color transparent.
stk delete.
""
].
].
].
" (self currentHand attachMorph: handle)."
" self currentHand addMorph:handle. "
self currentHand attachMorph:handle.
答案 0 :(得分:2)
代码有点混乱。有一点不合适的是
self handlesMouseDown: evt.
如果你想接收mouseDown:messages,那么它应该返回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.