1 |
6 |
Kragenwar-3044 |
import "Turbine.UI"; |
2 |
|
Kragenwar-3044 |
|
3 |
|
Kragenwar-3044 |
FontComboBox = class(KragenPlugs.UI.ComboBox); |
4 |
|
Kragenwar-3044 |
|
5 |
|
Kragenwar-3044 |
function FontComboBox:Constructor() |
6 |
|
Kragenwar-3044 |
KragenPlugs.UI.ComboBox.Constructor(self); |
7 |
|
Kragenwar-3044 |
end |
8 |
|
Kragenwar-3044 |
|
9 |
|
Kragenwar-3044 |
function FontComboBox:AddItem(text, value, size) |
10 |
|
Kragenwar-3044 |
local width, height = self.listBox:GetSize(); |
11 |
|
Kragenwar-3044 |
|
12 |
|
Kragenwar-3044 |
local listItem = Turbine.UI.Label(); |
13 |
|
Kragenwar-3044 |
listItem:SetSize(width, size); |
14 |
|
Kragenwar-3044 |
listItem:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleCenter); |
15 |
|
Kragenwar-3044 |
listItem:SetForeColor(ComboBox.ItemColor); |
16 |
|
Kragenwar-3044 |
listItem:SetFont(value); |
17 |
|
Kragenwar-3044 |
listItem:SetOutlineColor(ComboBox.HighlightColor); |
18 |
|
Kragenwar-3044 |
listItem:SetText(text); |
19 |
|
Kragenwar-3044 |
|
20 |
|
Kragenwar-3044 |
listItem.MouseEnter = function(sender, args) |
21 |
|
Kragenwar-3044 |
sender:SetFontStyle(Turbine.UI.FontStyle.Outline); |
22 |
|
Kragenwar-3044 |
sender:SetForeColor(ComboBox.ItemColor); |
23 |
|
Kragenwar-3044 |
sender:SetText(sender:GetText()); |
24 |
|
Kragenwar-3044 |
end |
25 |
|
Kragenwar-3044 |
listItem.MouseLeave = function(sender, args) |
26 |
|
Kragenwar-3044 |
sender:SetFontStyle(Turbine.UI.FontStyle.None); |
27 |
|
Kragenwar-3044 |
if (self.listBox:IndexOfItem(sender) == self.selection) then |
28 |
|
Kragenwar-3044 |
sender:SetForeColor(ComboBox.SelectionColor); |
29 |
|
Kragenwar-3044 |
end |
30 |
|
Kragenwar-3044 |
sender:SetText(sender:GetText()); |
31 |
|
Kragenwar-3044 |
end |
32 |
|
Kragenwar-3044 |
listItem.MouseClick = function(sender, args) |
33 |
|
Kragenwar-3044 |
if (args.Button == Turbine.UI.MouseButton.Left) then |
34 |
|
Kragenwar-3044 |
self:ItemSelected(self.listBox:GetSelectedIndex()); |
35 |
|
Kragenwar-3044 |
self:FireEvent(); |
36 |
|
Kragenwar-3044 |
end |
37 |
|
Kragenwar-3044 |
end |
38 |
|
Kragenwar-3044 |
listItem.value = value; |
39 |
|
Kragenwar-3044 |
self.listBox:AddItem(listItem); |
40 |
|
Kragenwar-3044 |
end |