2017-01-06 6 views
0

プレーヤー内で、選択範囲(開始時刻と終了時刻)を手動でドラッグできるようにしたいと考えています。 ユーザーがドラッグを開始するかどうかを確認するには、dragStartメッセージを使用できますが、ユーザーがいつドラッグを停止するか分からないため、要素の最終的な位置を取得できません。Livecode player: "dragStop"メッセージをキャッチする方法

私はこのような何かを試してみました:

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 

しかし、プレーヤーはwaitコマンドで凍結されています。したがって、ユーザーは境界線を移動することができず、「endTime」の最終的な位置を取得することはできません。

マウスが上がるまで待つ方法、プレーヤーはフリーズしないでください。

答えて

0

これは、最終的には非常に簡単なコード(しばしば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 
1

ブロッキングループから抜け出し、「メッセージとともに」待っているか、またはその間にエンジンを解放するハンドラ内で時間内にメッセージを送信する方法はたくさんあります。しかし、あなたが実験を試みるなら、最も基本的なものがこのようなものかもしれません。新しいカードにボタンとフィールドを作成します。ボタンスクリプト内:

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 

これは過度ですが、小さなハンドラーを使って小さな問題を処理する方法を少なくとも示しています。

関連する問題