GuiButton

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

作成できません
閲覧できません

GUIボタンは、GuiObject から継承された抽象クラスです。ImageButton および Class

GUIボタンの最も重要なイベントは、GuiButton.Activated、多プラットフォームイベントで、ボタンがアクティブになると発動します。マウス

概要

プロパティ

  • 並列読み取り

    マウスがその上に停止するか、クリックするとボタンの色が自動的に変更されるかどうかを決定します。

  • 並列読み取り

    GUI 要素が表示されている場合、マウスは右マウスボタンが下にあるまでロックされません。

  • 並列読み取り

    オブジェクトが選択されているかどうかを示すBooleanプロパティ。

  • 並列読み取り

    プリデターミンスタイルのリストに基づいてGUIボタンのスタイルを設定します。

GuiObject から継承した プロパティ
  • 並列読み取り

    この UI 要素が入力を沈めるかどうかを決定します。

  • 並列読み取り

    Class.GuiObject のオリジンポイントを決定し、相対的なサイズに対して Class.GuiObject のオリジンポイントを決定します。

  • 子コンテンツに基づいてサイズ変更が発生するかどうかを決定します。

  • 並列読み取り

    Class.GuiObject の背景色を決定します。

  • 並列読み取り

    Class.GuiObject の背景と境界を透明化する。

  • 並列読み取り

    Class.GuiObject ボーダーの色を決定します。

  • 並列読み取り

    Class.GuiObject ボーダーの位置相対を決定します。

  • 並列読み取り

    Class.GuiObject ボーダーのピクセル幅を決定します。

  • 並列読み取り

    親 GUI 要素の外にある子 GUI 要素がレンダリングするべきかどうかを決定します。

  • 読み取り専用
    複製されていません
    並列読み取り

    プレイヤーのマウスが GuiObject 上で積極的に押されているかどうかを決定します。

  • 並列読み取り

    Class.GuiButton がインタラクト可能かどうかを決定します。GuiStateGuiObject が変更されているかどうか。

  • 並列読み取り

    Class.UIGridStyleLayout と一緒に使用されると、UIGridStyleLayout のソートオーダーを制御します。

  • 並列読み取り

    ゲームパッドのセレクターが下に移動すると、GuiObject が選択されます。

  • 並列読み取り

    ゲームパッドのセレクターが左に移動したときに選択される GuiObject を設定します。

  • 並列読み取り

    ゲームパッドのセレクターが右に移動したときに選択される GuiObject を設定します。

  • 並列読み取り

    ゲームパッドセレクターが上に移動すると、GuiObject が選択されます。

  • 並列読み取り

    Class.GuiObject のピクセルとスカラーポジションを決定します。

  • 並列読み取り

    Class.GuiObject が回転する度数を決定します。

  • 並列読み取り

    ゲームパッドで GUI を選択できるかどうかを決定します。

  • ゲームパッドのデフォルトの装飾をオーバーライドします。

  • 並列読み取り

    ゲームパッド UI の選択によって選択された GuiObjects のオーダー。

  • 並列読み取り

    Class.GuiObject のピクセルとスケーラーサイズを決定します。

  • 親のサイズに対応する SizeGuiObject 軸を設定します。

  • 非表示
    複製されていません
    並列読み取り
    非推奨

    Class.GuiObject.BackgroundTransparency|BackgroundTransparency と TextTransparency のミックスプロパティ。

  • 並列読み取り

    Class.GuiObject とその子孫がレンダリングされるかどうかを決定します。

  • 並列読み取り

    他の Class.GuiObject との相対位置で GuiObject がレンダリングされる順序を決定します。

GuiBase2d から継承した プロパティ

方法

GuiObject から継承した 方法

イベント

GuiObject から継承した イベントGuiBase2d から継承した イベント
  • SelectionChanged(amISelected : bool,previousSelection : GuiObject,newSelection : GuiObject):RBXScriptSignal

    ゲームパッドの選択が移動すると、退出します。または、接続された GuiBase2d または任意の子 GuiObjects 内で変更されます。

プロパティ

AutoButtonColor

並列読み取り

ボタンの色を変更するのは、ユーザーの Mouse がホバーしたまたはクリックしたときに自動的にボタンの色が変更されるかどうかです。

[ボタン] をホバーしたまたはクリックすると、ボタンの色が自動的に変更されます。[ボタン] を偽定すると、ボタンは変更されません。

ユーザーのマウスがホバーオーバーしたまたはクリックしたときにボタンの変更方法をカスタマイズしたい場合は、<a href="https://www.Class.ImageButton.com/Button/Button.html"> Class.ImageButton</a> GUIを使用し、エレメントの<a href="https://www.Class.ImageButton.com/Button/Button.html"> Class.ImageButton.HoverImage</a> および<a href="https://www.Class.

このプロパティは、ImageButtonImageButton.Image プロパティを設定している場合、および ImageButton.HoverImage が nullではない場合には影響しません。さらに、2>Class.ImageButton.PressedImage2>

コードサンプル

The code below enables a button's GuiButton.AutoButtonColor as long as it it not a ImageButton with ImageButton.HoverImage and ImageButton.PressedImage properties set to images.

In order for the code to work as expected, it must be placed in a LocalScript that is a child of the button.

Changing a GUI Button's Color on Hover and Click

local button = script.Parent
if button:IsA("ImageButton") then
if button.HoverImage and button.ClickImage then
return
end
end
button.AutoButtonColor = true
並列読み取り

GUI 要素が表示されている場合、マウスは右マウスボタンが下にあるまでロックされません。

Selected

並列読み取り

オブジェクトが選択されているかどうかを示すBooleanプロパティ。

並列読み取り

プリデターミンスタイルのリストに基づいてGUIボタンのスタイルを設定します。

方法

イベント

Activated

ボタンが有効になるとファイアされます。このイベントは、サーバーにファイアされることはありませんので、LocalScript または ScriptRunContext のみに使用されるべきです。2>Enums.RunContext.Client2> の 5>Class.Script5> の中

パラメータ

inputObject: InputObject
clickCount: number

MouseButton1Click

マウスボタン1クリックイベントは、ユーザーの Mouse が完全に左クリックしたときに発動します。

クリックすると、マウスはボタンの範囲内にある必要があり、ボタンを押し下げてから再び押し上げる必要があります。このイベントが発動する前に、マウスがボタンの範囲を離れてリリースされると、イベントは発動しません。この限定を避

このイベントは GuiButton.MouseButton2Click と似ていますが、ユーザーの右マウスボタンに接続されているだけです。

このイベントは、TextButtonsImageButton など、GUI ボタンのみを有効にすることに注意してください。他の GuiObjects には発射しません。


コードサンプル

The code sample below demonstrates how to use the GuiButton.MouseButton1Click and GuiButton.MouseButton2Click events to handle user left and right mouse button input on a GuiButton.

For the example to work expected, the LocalScript containing the code should be a child of the GUI button.

Handling User Clicks on a GUI Button

local button = script.Parent
local function leftClick()
print("Left mouse click")
end
local function rightClick()
print("Right mouse click")
end
button.MouseButton1Click:Connect(leftClick)
button.MouseButton2Click:Connect(rightClick)

MouseButton1Down

マウスボタン1ダウンイベントは、ユーザーが GUI オブジェクトの左側の Mouse ボタンを下に押すと発動します。

このイベントは GuiButton.MouseButton2Down と似ていますが、ユーザーの右マウスボタンに接続されているだけです。

ユーザーが左マウスを押してリリースする必要があるイベントを GUI で発動するには、GuiButton.MouseButton1Click を使用してください。

このイベントは、TextButtonsImageButton など、GUI ボタンのみを有効にすることに注意してください。他の GuiObjects には発射しません。

パラメータ

マウスの X 画面コーディネートをピクセル単位で表示します。

マウスの Y 軸コーディネート。


コードサンプル

The code sample below demonstrates how to use the GuiButton.MouseButton1Up and GuiButton.MouseButton1Down events to handle user input when the left mouse button is pressed down and released up on a GuiButton.

For the example to work expected, the LocalScript containing the code should be a child of the GUI button.

Handling Right Mouse Button Up/Down on a GUI Button

local button = script.Parent
local function leftMouseButtonUp(x, y)
print("Left mouse up at", x, y)
end
local function leftMouseButtonDown(x, y)
print("Left mouse down at", x, y)
end
button.MouseButton1Up:Connect(leftMouseButtonUp)
button.MouseButton1Down:Connect(leftMouseButtonDown)

MouseButton1Up

マウスボタン1アップイベントは、ユーザーが GUI オブジェクトから左にMouseにリリースすると発動します。

このイベントは GuiButton.MouseButton2Up と似ていますが、ユーザーの右マウスボタンに接続されているだけです。

ユーザーが左マウスを押してリリースする必要があるイベントを GUI で発動するには、GuiButton.MouseButton1Click を使用してください。

このイベントは、TextButtonsImageButton など、GUI ボタンのみを有効にすることに注意してください。他の GuiObjects には発射しません。

パラメータ

マウスの X 画面コーディネートをピクセル単位で表示します。

マウスの Y 軸コーディネート。


コードサンプル

The code sample below demonstrates how to use the GuiButton.MouseButton1Up and GuiButton.MouseButton1Down events to handle user input when the left mouse button is pressed down and released up on a GuiButton.

For the example to work expected, the LocalScript containing the code should be a child of the GUI button.

Handling Right Mouse Button Up/Down on a GUI Button

local button = script.Parent
local function leftMouseButtonUp(x, y)
print("Left mouse up at", x, y)
end
local function leftMouseButtonDown(x, y)
print("Left mouse down at", x, y)
end
button.MouseButton1Up:Connect(leftMouseButtonUp)
button.MouseButton1Down:Connect(leftMouseButtonDown)

MouseButton2Click

マウスボタン 2 クリックイベントは、ユーザーの Mouse が完全に右クリックしたときに発動します。

クリックすると、マウスはボタンの範囲内にある必要があり、ボタンの下に押され、再び上に押される必要があります。マウスがボタンの範囲を離れてリリースされると、イベントは発動しません。 if (Windows.Event.MouseMove.MouseMove2Down) Class.GuiButton.

このイベントは GuiButton.MouseButton1Click と似ていますが、ユーザーの左マウスボタンに接続されているだけです。

このイベントは、TextButtonsImageButton など、GUI ボタンのみを有効にすることに注意してください。他の GuiObjects には発射しません。


コードサンプル

Demonstrates how to use the GuiButton.MouseButton2Click event to detect when a user right clicks a GuiButton.

The mouse has to be in bounds of the button and has to be pressed down and up again before this event fires.

Note: place the "RightClickScreenGui" within StarterGui for this sample to work properly.

GUI Button Right Click

local button = script.Parent.Button
local function rightClick()
print("Right click pressed down and up on button.")
end
button.MouseButton2Click:Connect(rightClick)

MouseButton2Down

マウスボタン2ダウンイベントは、ユーザーが GUI オブジェクトの下にある Mouse ボタンを押すと発動します。

このイベントは GuiButton.MouseButton1Down と似ていますが、ユーザーの左マウスボタンに接続されているだけです。

ユーザーが右マウスを押してリリースする必要があるイベントを GUI で発動するには、GuiButton.MouseButton2Click を使用してください。

このイベントは、TextButtonsImageButton など、GUI ボタンのみを有効にすることに注意してください。他の GuiObjects には発射しません。

パラメータ

マウスの X 画面コーディネートをピクセル単位で表示します。

マウスの Y 軸コーディネート。


コードサンプル

The code sample below demonstrates how to use the GuiButton.MouseButton2Up and GuiButton.MouseButton2Down events to handle user input when the right mouse button is pressed down and released up on a GuiButton.

For the example to work expected, the LocalScript containing the code should be a child of the GUI button.

Handling Left Mouse Button Up/Down on a GUI Button

local gui = script.Parent
local button = gui.Button
function rightMouseButtonUp(x, y)
print("Right mouse up", x, y)
end
function rightMouseButtonDown(x, y)
print("Right mouse down", x, y)
end
button.MouseButton2Up:Connect(rightMouseButtonUp)
button.MouseButton2Down:Connect(rightMouseButtonDown)

MouseButton2Up

マウスボタン 2 アップイベントは、ユーザーが GUI オブジェクトから右に Mouse に解放すると発動します。

このイベントは GuiButton.MouseButton1Up と似ていますが、ユーザーの左マウスボタンに接続されているだけです。

ユーザーが右マウスを押してリリースする必要があるイベントを GUI で発動するには、GuiButton.MouseButton2Click を使用してください。

このイベントは、TextButtonsImageButton など、GUI ボタンのみを有効にすることに注意してください。他の GuiObjects には発射しません。

パラメータ

マウスの X 画面コーディネートをピクセル単位で表示します。

マウスの Y 軸コーディネート。


コードサンプル

The code sample below demonstrates how to use the GuiButton.MouseButton2Up and GuiButton.MouseButton2Down events to handle user input when the right mouse button is pressed down and released up on a GuiButton.

For the example to work expected, the LocalScript containing the code should be a child of the GUI button.

Handling Left Mouse Button Up/Down on a GUI Button

local gui = script.Parent
local button = gui.Button
function rightMouseButtonUp(x, y)
print("Right mouse up", x, y)
end
function rightMouseButtonDown(x, y)
print("Right mouse down", x, y)
end
button.MouseButton2Up:Connect(rightMouseButtonUp)
button.MouseButton2Down:Connect(rightMouseButtonDown)