API version 1
- ‐
doDragDrop¶
ドラッグ&ドロップを開始します。
このメソッドが完了すると、それまでにsetStringメソッド等で設定したデータはすべてクリアされます。
呼出形式一覧
呼出形式 |
説明 |
---|---|
void doDragDrop([integer type]) |
ドラッグ&ドロップを開始します。 |
戻り値一覧
戻り値 |
説明 |
---|---|
void |
なし |
引数一覧
引数 |
説明 |
||||||
---|---|---|---|---|---|---|---|
type |
ドラッグ&ドロップの種類 以下の値を指定します。省略時はDROP_COPYMODEになります。
|
例外
なし
定数一覧
------------------------------------------------------------
定数値 |
説明 |
---|---|
DROP_COPYMODE |
256:コピーモード |
DROP_MOVEMODE |
512:移動モード |
使用例
CRSダウンロード
ダウンロード(neko1.jpg)
Form DragSource {
X = 0;
Y = 0;
Width = 765;
Height = 494;
number flg;
Number num;
/*
画像サンプル(neko1.jpg)とcrsは同じディレクトリで実行してください。
Designerでの実行の場合は画像をプロジェクトに登録します。
*/
Image Image1 {
var fs = new FileSystem;
var file1 = fs.Open("neko1.jpg",FileSystem.OPEN_READ);
/* LoadImage(file1); */
LoadImage("neko1.jpg");
}
Label Label3 {
x = 21;
y = 28;
Width = 331;
Height = 20;
Value = "他のオブジェクトへドラッグ&ドロップ";
Font = new Font( "", "", true );
}
/* ドロップ元のオブジェクト(Value) */
TextBox ValueObject[3] {
x = 20;
y = 68;
Width = 60;
Height = 24;
Layout = LAYOUT_HORIZONTAL;
this[0].Value = "あいうえお";
this[1].Value = "abcde";
this[2].Value = 12345;
Function OnClicked( e ) {
/* 自分自身をドラッグオブジェクトに設定してドラッグを開始します */
try {
^.flg=1;
var ds = new DragSource;
ds.SetObject( this );
ds.DoDragDrop( DROP_COPYMODE ); # 下を使うとmoveになります
/* ds.DoDragDrop( DROP_MOVEMODE ); */
} catch ( e ) {
^.EditBox_err.Value = "Message=" + str(e.Message) + "\r\nCategory=" + str(e.Category) + "\r\nCode="+ str(e.Code) + "\r\nSubCode=" + str(e.subCode);
}
}
}
/* ドロップ元のオブジェクト(BgColor) */
Label BgColorObject[3] {
x = 30;
y = 113;
Width = 56;
Height = 24;
Layout = LAYOUT_HORIZONTAL;
this[0].BgColor = Color.RED;
this[0].Value = "Red";
this[1].BgColor = Color.BLUE;
this[1].Value = "Blue";
this[2].BgColor = Color.YELLOW;
this[2].Value = "Yellow";
Function OnClicked( e ) {
/* 自分自身をドラッグオブジェクトに設定してドラッグを開始します */
try {
^.flg = 2;
var ds = new DragSource;
ds.SetObject( this );
ds.DoDragDrop( DROP_COPYMODE );
/* ds.DoDragDrop( DROP_MOVEMODE ); */
} catch ( e ) {
^.EditBox_err.Value = "Message=" + str(e.Message) + "\r\nCategory=" + str(e.Category) + "\r\nCode="+ str(e.Code) + "\r\nSubCode=" + str(e.subCode);
}
}
}
/* ドロップ元のオブジェクト(Image) */
Label lbl_img {
x = 34;
y = 157;
width = 140;
height = 130;
Border = 4;
image = ^.Image1 ;
Function onClicked(e) {
try {
^.flg = 3;
var ds = new DragSource();
ds.setObject(this);
ds.setImage(^.Image1) ;
ds.DoDragDrop( DROP_COPYMODE );
/* ds.DoDragDrop( DROP_MOVEMODE ); */
} catch ( e ) {
^.EditBox_err.Value = "Message=" + str(e.Message) + "\r\nCategory=" + str(e.Category) + "\r\nCode="+ str(e.Code) + "\r\nSubCode=" + str(e.subCode);
}
}
}
Label Label17 {
x = 210;
y = 72;
Width = 25;
Height = 24;
Value = "→";
}
Label Label1 {
x = 210;
y = 116;
Width = 25;
Height = 24;
Value = "→";
}
Label Label12 {
x = 210;
y = 162;
Width = 25;
Height = 24;
Value = "→";
}
/* ドロップ先のオブジェクト */
Label lbl_drop {
x = 241;
y = 70;
Width = 178;
Height = 130;
Value = "ここへドロップします";
Border = true;
BgColor = Color.WHITE;
AcceptDrop = DROP_OBJECT + DROP_COPYMODE + DROP_MOVEMODE;
Function OnDropped( e ) {
switch(^.flg) {
case 1:
value = e.data.value;
if ( e.mode == 512 ){
^.ValueObject[^.num].Clear();
^.num = 0;
}
break;
case 2:
lbl_drop.BgColor = e.data.Value;
if (^.OptionButton1.Value == 1) {
^.BgColorObject[^.num].BgColor = Color.STD;
^.num = 0;
}
break;
case 3:
Value = e.data.value;
image = e.data.image;
^.num = 0;
}
^.Kekka1.Value = e.mode;
}
}
/* 結果(e.Mode) */
Label Label10 {
x = 289;
y = 227;
width = 105;
Height = 14;
Value = "e.Modeプロパティ値";
}
Label Kekka1 {
x = 303;
y = 245;
Width = 78;
Height = 39;
Border = true;
}
}