画面操作 - マウス
マウスをクリックした時にオブジェクトの色を変えて、ボタンを離したら元の色に戻したい
DisplayObjectクラスを継承するクラスは、クラス定義内にClickedイベント、LButtonUpイベント
のイベントハンドラをそれぞれ記述し、さらにイベント内でBgColorプロパティを変更する処理を
記述することでマウスをクリックした時にオブジェクトの色を変更し、
ボタンを離すことで元の色に戻すことができます。
例)
Clickedイベント内の処理にはBgColorプロパティにオブジェクトのクリック時に変更する色を設定
LButtonUpイベント内の処理にはBgColorプロパティにボタンを離したときに戻す色を設定
############################################################### # 画面操作−マウス # マウスをクリックした時にオブジェクトの色を変えて、ボタンを離したら元の色に戻したい ############################################################### Form ScO00210 { x = 0; y = 0; width = 800; height = 600; Label label2 { x = 10; y = 10; width = 780; height = 82; Value = "画面操作 − マウス"; font = new Font("MS UI Gothic", 20, true); horizontalAlign = ALIGN_LEFT; verticalAlign = ALIGN_CENTER; Border = New Border( Border.SOLID, 2, Color.BLACK); } Label label1 { x = 16; y = 116; width = 775; height = 459; horizontalAlign = ALIGN_LEFT; verticalAlign = ALIGN_TOP; value = "\nマウスをクリックした時にオブジェクトの色を変えて、ボタンを離したら元の色に戻したい"; } GroupBox groupbox1 { x = 10; y = 109; width = 780; height = 461; TabIndex = 1000; Border = New Border( Border.SOLID, 2, Color.BLACK); ############################################### # クラスタイトル ############################################### Label label1 { x = 80; y = 55; width = 105; height = 40; horizontalAlign = ALIGN_CENTER; verticalAlign = ALIGN_CENTER; Value = "ボタン:"; } Label label3 { x = 80; y = 131; width = 105; height = 40; horizontalAlign = ALIGN_CENTER; verticalAlign = ALIGN_CENTER; Value = "ラベル:"; } Label label4 { x = 80; y = 207; width = 105; height = 40; horizontalAlign = ALIGN_CENTER; verticalAlign = ALIGN_CENTER; Value = "フォーム:"; } Label label5 { x = 80; y = 291; width = 105; height = 40; horizontalAlign = ALIGN_CENTER; verticalAlign = ALIGN_CENTER; Value = "テキストボックス:"; } ############################################### # ボタンクラス ############################################### Button button1 { x = 186; y = 52; width = 361; height = 45; TabIndex = 33; BgColor = COLOR.STD; #デフォルトのカラー色を設定 #クリック中のイベント処理 function onClicked(e){ BgColor = COLOR.RED; #ボタン押下時のカラー色を設定 } #ボタンを離したときの処理 function onLButtonUp(e){ #ボタン非押下時のカラー色を設定 BgColor = COLOR.STD; } } ############################################### # ラベルクラス ############################################### Label label2 { x = 186; y = 128; width = 361; height = 45; Border = New Border( Border.SOLID, 1, COLOR.DGRAY ); BgColor = COLOR.STD; #デフォルトのカラー色を設定 #クリック中のイベント処理 function onClicked(e){ BgColor = COLOR.RED; #ボタン押下時のカラー色を設定 } #ボタンを離したときの処理 function onLButtonUp(e){ #ボタン非押下時のカラー色を設定 BgColor = COLOR.STD; } } ############################################### # フォームクラス ############################################### Form form1 { x = 186; y = 206; width = 361; height = 45; Border = New Border( Border.SOLID, 1, COLOR.DGRAY ); BgColor = COLOR.STD; #デフォルトのカラー色を設定 #クリック中のイベント処理 function onClicked(e){ BgColor = COLOR.RED; #ボタン押下時のカラー色を設定 } #ボタンを離したときの処理 function onLButtonUp(e){ #ボタン非押下時のカラー色を設定 BgColor = COLOR.STD; } } ############################################### # テキストボックスクラス ############################################### TextBox textbox1 { x = 186; y = 289; width = 361; height = 45; Border = New Border( Border.SOLID, 1, COLOR.DGRAY ); BgColor = COLOR.STD; #デフォルトのカラー色を設定 #クリック中のイベント処理 function onClicked(e){ BgColor = COLOR.RED; #ボタン押下時のカラー色を設定 } #ボタンを離したときの処理 function onLButtonUp(e){ #ボタン非押下時のカラー色を設定 BgColor = COLOR.STD; } } } }
Biz-Collections Bizの宝箱 トップへ
Biz/Browser DT・Biz/Designer DT TIPS集 トップへ