# MatSelect

- **Ortam:** İstemci
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/MatSelect
- **Çeviri tarihi:** 2025-09-08

## Açıklama

Material & Lamba Sandbox araçları tarafından doku seçimi için kullanılan panel. Yalnızca Sandbox'ta kullanılmasına rağmen, bu oyun moduna özel **değildir**.

Prop seçme alternatifi için ayrıca bakınız: [PropSelect](https://gmod.tr/wiki/PropSelect).

[Kaynağı görüntüle](https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/matselect.lua)

## Ebeveyn

Bu sayfada listelenmeyen metotları vb. [ContextBase](https://gmod.tr/wiki/ContextBase)'den türetir.

## Uygular

Aşağıdaki kancaları/metotları uygular veya geçersiz kılar. Bunları geçersiz kılmak isterseniz, muhtemelen orijinal fonksiyonu da çağırmanız gerekir.

- [Panel:Clear](https://gmod.tr/wiki/Panel:Clear)
- [ContextBase:TestForChanges](https://gmod.tr/wiki/ContextBase:TestForChanges)
- [PANEL:Init](https://gmod.tr/wiki/PANEL:Init)
- [PANEL:PerformLayout](https://gmod.tr/wiki/PANEL:PerformLayout)

## Olaylar

MatSelect:[OnRightClick](https://gmod.tr/wiki/MatSelect:OnRightClick)( [Panel](https://gmod.tr/wiki/Panel) pnl )

Oyuncu bir materyale sağ tıkladığında çağrılır. Varsayılan olarak bu, oyuncunun materyal yolunu kopyalamasına olanak tanıyan bir menü açar.

MatSelect:[OnSelect](https://gmod.tr/wiki/MatSelect:OnSelect)( [string](https://gmod.tr/wiki/string) material, [Panel](https://gmod.tr/wiki/Panel) pnl )

Oyuncu bir materyal seçtiğinde çağrılır.

MatSelect:[SelectedItemPaintOver](https://gmod.tr/wiki/MatSelect:SelectedItemPaintOver)( [number](https://gmod.tr/wiki/number) w, [number](https://gmod.tr/wiki/number) h )

Bir DImageButton seçildiğinde onun için bir üzerine çizim fonksiyonu tanımlar. Bu fonksiyonun bağlamında `self`, DImageButton'ın kendisidir!

## Metotlar

MatSelect:[AddMaterial](https://gmod.tr/wiki/MatSelect:AddMaterial)( [string](https://gmod.tr/wiki/string) label, [string](https://gmod.tr/wiki/string) path )

Seçim listesine yeni bir materyal ekler.

MatSelect:[AddMaterialEx](https://gmod.tr/wiki/MatSelect:AddMaterialEx)( [string](https://gmod.tr/wiki/string) label, [string](https://gmod.tr/wiki/string) path, [any](https://gmod.tr/wiki/any) value, [table](https://gmod.tr/wiki/table) convars )

Seçim listesine, bazı ekstra seçeneklerle birlikte yeni bir materyal ekler.

MatSelect:[FindAndSelectMaterial](https://gmod.tr/wiki/MatSelect:FindAndSelectMaterial)( [string](https://gmod.tr/wiki/string) mat )

Bu panelde mevcutsa bir materyal bulur ve seçer.

[DImageButton](https://gmod.tr/wiki/DImageButton) MatSelect:[FindMaterialByValue](https://gmod.tr/wiki/MatSelect:FindMaterialByValue)( [string](https://gmod.tr/wiki/string) mat )

Girdi materyal yoluna göre bir DImageButton paneli bulur.

[boolean](https://gmod.tr/wiki/boolean) MatSelect:[GetAutoHeight](https://gmod.tr/wiki/MatSelect:GetAutoHeight)()

Panelin, tüm materyalleri kendi yüksekliğine sığdırmak için kendi yüksekliğini ayarlayıp ayarlamayacağını döndürür.

MatSelect:[SelectMaterial](https://gmod.tr/wiki/MatSelect:SelectMaterial)( [DImageButton](https://gmod.tr/wiki/DImageButton) mat )

Bu dahili olarak kullanılır - kullanabilseniz de muhtemelen kullanmamalısınız. Bunun yerine MatSelect:FindAndSelectMaterial kullanın. Verilen bir materyal panelini seçer.

MatSelect:[SetAutoHeight](https://gmod.tr/wiki/MatSelect:SetAutoHeight)( [boolean](https://gmod.tr/wiki/boolean) autoSize )

Panelin, tüm materyalleri kendi yüksekliğine sığdırmak için kendi yüksekliğini ayarlayıp ayarlamayacağını belirler.

MatSelect:[SetItemHeight](https://gmod.tr/wiki/MatSelect:SetItemHeight)( [number](https://gmod.tr/wiki/number) height )

Tek bir materyalin yüksekliğini piksel cinsinden ayarlar.

MatSelect:[SetItemWidth](https://gmod.tr/wiki/MatSelect:SetItemWidth)( [number](https://gmod.tr/wiki/number) width )

Tek bir materyalin genişliğini piksel cinsinden ayarlar.

MatSelect:[SetNumRows](https://gmod.tr/wiki/MatSelect:SetNumRows)( [number](https://gmod.tr/wiki/number) rows )

Panelin hedef yüksekliğini satır sayısı olarak ayarlar.

### Örnek

Panelin örnek kullanımı.

```lua
local frame = vgui.Create( "DFrame" )
frame:SetSize( 500, 500 )
frame:Center()
frame:MakePopup()

local MatSelect = vgui.Create( "MatSelect", frame )
MatSelect:Dock( TOP )
Derma_Hook( MatSelect.List, "Paint", "Paint", "Panel" )

-- MatSelect:SetConVar( "my_convar_name" )

MatSelect:SetAutoHeight( true )
MatSelect:SetItemWidth( 64 )
MatSelect:SetItemHeight( 64 )

local items = {
	"effects/flashlight001",
	"effects/flashlight/slit",
	"effects/flashlight/circles"
}

for k, material in pairs( items ) do
	MatSelect:AddMaterial( "Item #" .. k, material )
end

function MatSelect:OnSelect( mat, pnl )
	print( "Selected material: ", mat )
end
```

**Çıktı:**

![image.png](https://gmod.tr/api/uploads/wiki/d4e288d27db3c35f673b.png)

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/MatSelect
