Livecode 播放器:如何赶上 "dragStop" 消息
Livecode player: How to catch up a "dragStop" message
在播放器中,我想允许用户手动拖动选择的边界(开始时间和结束时间)。
我可以使用 dragStart 消息来捕捉用户是否开始拖动,但我无法获得元素的最终位置,因为我不知道用户何时停止拖动.
我试过这样的方法:
on dragStart
repeat until the mouse is up
/*unfortunately, this part freeze the player*/
end repeat
put the timeScale of me into sr
put the endTime of me into endT
put endT/sr
end dragStart
但是播放器被等待命令冻结了。所以用户无法移动边界,我也无法获得 "endTime".
的最终位置
如何等到鼠标抬起,而不冻结播放器?
有很多方法可以摆脱阻塞循环,等待 "with messages" 或在处理程序中及时发送消息,这会在间隔期间释放引擎。但最基本的可能是这样的,如果你想做一个实验的话。在新卡片上制作一个按钮和一个字段。在按钮脚本中:
on dragStart
put the loc of me into line 1 of fld 1
end dragStart
on mouseMove
if the mouseLoc is within the rect of me and the mouse is down then
set the loc of me to the mouseLoc
end if
end mouseMove
on mouseup
put the loc of me into line 2 of fld 1
end mouse up
现在这有点过头了,但至少展示了如何使用小型处理程序来处理小问题。
这最终可以通过一个非常简单的代码来实现(通常使用 livecode):
on selectionchanged
put the timeScale of me into sr
put the endTime of me into endT
put endT/sr into fld 1
end selectionchanged
在播放器中,我想允许用户手动拖动选择的边界(开始时间和结束时间)。 我可以使用 dragStart 消息来捕捉用户是否开始拖动,但我无法获得元素的最终位置,因为我不知道用户何时停止拖动.
我试过这样的方法:
on dragStart
repeat until the mouse is up
/*unfortunately, this part freeze the player*/
end repeat
put the timeScale of me into sr
put the endTime of me into endT
put endT/sr
end dragStart
但是播放器被等待命令冻结了。所以用户无法移动边界,我也无法获得 "endTime".
的最终位置如何等到鼠标抬起,而不冻结播放器?
有很多方法可以摆脱阻塞循环,等待 "with messages" 或在处理程序中及时发送消息,这会在间隔期间释放引擎。但最基本的可能是这样的,如果你想做一个实验的话。在新卡片上制作一个按钮和一个字段。在按钮脚本中:
on dragStart
put the loc of me into line 1 of fld 1
end dragStart
on mouseMove
if the mouseLoc is within the rect of me and the mouse is down then
set the loc of me to the mouseLoc
end if
end mouseMove
on mouseup
put the loc of me into line 2 of fld 1
end mouse up
现在这有点过头了,但至少展示了如何使用小型处理程序来处理小问题。
这最终可以通过一个非常简单的代码来实现(通常使用 livecode):
on selectionchanged
put the timeScale of me into sr
put the endTime of me into endT
put endT/sr into fld 1
end selectionchanged