PANEL:TestHover

  boolean PANEL:TestHover( number x, number y )

Açıklama

Paneli fare ile üzerinde durulup durulmadığını test etmek için çağrılır. Bu, yalnızca panelin ebeveyninin üzerinde duruluyorsa çağrılır.

Argümanlar

1 number x
İmlecin ekran uzayındaki x koordinatı.
2 number y
İmlecin ekran uzayındaki y koordinatı.

Döndürülenler

1 boolean
İmleç panelin üzerinde sayılmıyorsa false, panelin üzerinde sayılıyorsa true döndürün. Varsayılan davranış için herhangi bir şey döndürmeyin.

Örnek

Butonun tıklamaları dikdörtgen değil de daireselmiş gibi algılamasını sağlar.

concommand.Add( "testvgui1", function() local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 400 ) frame:Center() frame:MakePopup() local DermaButton = vgui.Create( "DButton", frame ) DermaButton:SetText( "Say hi" ) DermaButton:SetPos( 25, 50 ) DermaButton:SetSize( 250, 250 ) function DermaButton:DoClick( self ) chat.AddText( "Hello world" ) end function DermaButton:TestHover( x, y ) local x, y = self:ScreenToLocal( x, y ) -- Yerel koordinatlara dönüştür local dist = math.sqrt( (x - self:GetWide() / 2) ^ 2 + ( y - self:GetTall() / 2 ) ^ 2 ) -- Basit mesafe hesaplaması return dist < math.min( self:GetWide(), self:GetTall() ) / 2 -- İmleç butonun dairesel yarıçapı içindeyse true döndür end function DermaButton:Paint( w, h ) -- Orijinal boyut draw.RoundedBox( 0, 0, 0, w, h, Color( 255, 255, 255, 128 ) ) -- Dairesel görselleştirme local size = math.min( w, h ) / 2 surface.DrawCircle( w / 2, h / 2, size, Color( 255, 120, 0 ) ) end end )

Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord