T3STY
02-27-2010, 01:53 PM
As in thread's title, this is just a nonsense thing... in a project I have this function on my Global functions event:
function CreateButtons()
WinSize = Window.GetSize(Application.GetWndHandle());
for i, sButton in tblButtons do
tblNewButton = {};
TipoPulsante = INIFile.GetValue(ButtonsINI, sButton, "TipoPulsante");
PosizioneX = INIFile.GetValue(ButtonsINI, sButton, "PosizioneX");
tblNewButton.Width = tblTema.DimXButNormale;
tblNewButton.Height = tblTema.DimYButNormale;
if (PosizioneX == "$Middle") then
PosizioneX = ((WinSize.Width - 200) / 2 + 200);
else
PosizioneX = String.ToNumber(PosizioneX);
end
tblNewButton.ButtonFile = tblTema.ButNormale;
tblNewButton.Text = INIFile.GetValue(ButtonsINI, sButton, "Nome");
tblNewButton.FontName = tblTema.FontTexButNormale;
tblNewButton.FontSize = String.ToNumber(tblTema.DimTexButNormale);
tblNewButton.FontWeight = tblTema.BoldTexButNormale;
tblNewButton.ColorNormal = Math.HexColorToNumber(tblTema.ColTexButNormaleNorm ale);
tblNewButton.ColorHighlight = Math.HexColorToNumber(tblTema.ColTexButNormaleAcce so);
tblNewButton.ColorDown = Math.HexColorToNumber(tblTema.ColTexButNormaleClic cato);
tblNewButton.ColorDisabled = Math.HexColorToNumber(tblTema.ColTexButNormaleDisa bilitato);
tblNewButton.TooltipText = INIFile.GetValue(ButtonsINI, sButton, "TestoPopUp");
tblNewButton.Alignment = ALIGN_CENTER;
tblNewButton.HighlightSound = SND_NONE;
tblNewButton.ClickSound = SND_NONE;
tblNewButton.X = PosizioneX;
tblNewButton.Y = String.ToNumber(INIFile.GetValue(ButtonsINI, sButton, "PosizioneY"));
tblNewButton.Enabled = true;
tblNewButton.Cursor = CURSOR_HAND;
if (TipoPulsante == "1") then
tblNewButton.Style = BTNSTYLE_TOGGLE;
--> here tblNewButton.ToggleState = BTN_TOGGLE_UP;
--tblNewButton.ToggleState = BTN_UP;
elseif (TipoPulsante == "2") then
tblNewButton.Style = BTNSTYLE_TOGGLE;
--> here tblNewButton.ToggleState = BTN_TOGGLE_DOWN;
--tblNewButton.ToggleState = BTN_DOWN;
elseif (TipoPulsante == "0") then
tblNewButton.Style = BTNSTYLE_STANDARD;
tblNewButton.Cursor = CURSOR_ARROW;
end
Page.CreateObject(OBJECT_BUTTON, sButton, tblNewButton);
--> here if (TipoPulsante == 0) then
Width = (WinSize.Width - 200);
Button.SetEnabled(sButton, false);
Button.SetSize(sButton, Width, tblTema.DimYButNormale);
end
end
end
where you can read "here" there are the problems. So, what's the problem ?
When I call this function anything goes well while creating buttons, but:
-the toggle state is not set with the BTN_TOGGLE_UP/DOWN;
--this can be "fixed" by using BTN_UP/DOWN wich are the Button.SetState values.. WTH ??!
-I used a for..do function because I have to create lots of buttons with different properties.But there are buttons I need to be enabled, and buttons I need to be Disabled. Here we have another problem because if I set in the table the button as disabled, the first button in the list is set as disabled with it's disabled state image, but the next others are set as disabled with the normal state image. I solved by adding another if after creating thew button (3rd "here" in the code) but I don't like it like this.
Can anyone explain me why are those things happening and how can I fix this ?
p.s. Inthe table I've used also some variables from another table, called tblTema - an associative table, in the project wich is too long, almost unuseful for you. If you need it just ask.
p.p.s. Don't think about the language.. in my projects I'm used to use both English and Italian languages... :D
EDIT
I was forgetting!
When using BTN_UP/DOWN the buttons are set correctly in thge application but when the cursor enters application's window the buttons don't maintain their up/down state, they're state becomes UP for enabled buttons and disabled buttons remains as they're. What is this ? Do you think my AMS is having some issues ??
function CreateButtons()
WinSize = Window.GetSize(Application.GetWndHandle());
for i, sButton in tblButtons do
tblNewButton = {};
TipoPulsante = INIFile.GetValue(ButtonsINI, sButton, "TipoPulsante");
PosizioneX = INIFile.GetValue(ButtonsINI, sButton, "PosizioneX");
tblNewButton.Width = tblTema.DimXButNormale;
tblNewButton.Height = tblTema.DimYButNormale;
if (PosizioneX == "$Middle") then
PosizioneX = ((WinSize.Width - 200) / 2 + 200);
else
PosizioneX = String.ToNumber(PosizioneX);
end
tblNewButton.ButtonFile = tblTema.ButNormale;
tblNewButton.Text = INIFile.GetValue(ButtonsINI, sButton, "Nome");
tblNewButton.FontName = tblTema.FontTexButNormale;
tblNewButton.FontSize = String.ToNumber(tblTema.DimTexButNormale);
tblNewButton.FontWeight = tblTema.BoldTexButNormale;
tblNewButton.ColorNormal = Math.HexColorToNumber(tblTema.ColTexButNormaleNorm ale);
tblNewButton.ColorHighlight = Math.HexColorToNumber(tblTema.ColTexButNormaleAcce so);
tblNewButton.ColorDown = Math.HexColorToNumber(tblTema.ColTexButNormaleClic cato);
tblNewButton.ColorDisabled = Math.HexColorToNumber(tblTema.ColTexButNormaleDisa bilitato);
tblNewButton.TooltipText = INIFile.GetValue(ButtonsINI, sButton, "TestoPopUp");
tblNewButton.Alignment = ALIGN_CENTER;
tblNewButton.HighlightSound = SND_NONE;
tblNewButton.ClickSound = SND_NONE;
tblNewButton.X = PosizioneX;
tblNewButton.Y = String.ToNumber(INIFile.GetValue(ButtonsINI, sButton, "PosizioneY"));
tblNewButton.Enabled = true;
tblNewButton.Cursor = CURSOR_HAND;
if (TipoPulsante == "1") then
tblNewButton.Style = BTNSTYLE_TOGGLE;
--> here tblNewButton.ToggleState = BTN_TOGGLE_UP;
--tblNewButton.ToggleState = BTN_UP;
elseif (TipoPulsante == "2") then
tblNewButton.Style = BTNSTYLE_TOGGLE;
--> here tblNewButton.ToggleState = BTN_TOGGLE_DOWN;
--tblNewButton.ToggleState = BTN_DOWN;
elseif (TipoPulsante == "0") then
tblNewButton.Style = BTNSTYLE_STANDARD;
tblNewButton.Cursor = CURSOR_ARROW;
end
Page.CreateObject(OBJECT_BUTTON, sButton, tblNewButton);
--> here if (TipoPulsante == 0) then
Width = (WinSize.Width - 200);
Button.SetEnabled(sButton, false);
Button.SetSize(sButton, Width, tblTema.DimYButNormale);
end
end
end
where you can read "here" there are the problems. So, what's the problem ?
When I call this function anything goes well while creating buttons, but:
-the toggle state is not set with the BTN_TOGGLE_UP/DOWN;
--this can be "fixed" by using BTN_UP/DOWN wich are the Button.SetState values.. WTH ??!
-I used a for..do function because I have to create lots of buttons with different properties.But there are buttons I need to be enabled, and buttons I need to be Disabled. Here we have another problem because if I set in the table the button as disabled, the first button in the list is set as disabled with it's disabled state image, but the next others are set as disabled with the normal state image. I solved by adding another if after creating thew button (3rd "here" in the code) but I don't like it like this.
Can anyone explain me why are those things happening and how can I fix this ?
p.s. Inthe table I've used also some variables from another table, called tblTema - an associative table, in the project wich is too long, almost unuseful for you. If you need it just ask.
p.p.s. Don't think about the language.. in my projects I'm used to use both English and Italian languages... :D
EDIT
I was forgetting!
When using BTN_UP/DOWN the buttons are set correctly in thge application but when the cursor enters application's window the buttons don't maintain their up/down state, they're state becomes UP for enabled buttons and disabled buttons remains as they're. What is this ? Do you think my AMS is having some issues ??