Confused! :(

Feb 11, 2008 at 3:00 PM
What is wrong with this code?

function Button1_OnClick()
lblText:SetText("One");
end
function Button2_OnClick()
lblText:SetText("Two");
end
function Button3_OnClick()
lblText:SetText("Three");
end

The first function works but the second and third do not!
And yes, the buttons are the correct names, etc.
Feb 12, 2008 at 1:56 PM
I dont see any "error" in code, but there is still possibility that you dont register OnClick event in xml
Feb 12, 2008 at 9:55 PM
Edited Feb 12, 2008 at 10:20 PM
I thought the UI did all that.
It does it for the first button. Why not the others?
I will check the xml,
Thanks :)

{Edit: typo}
Feb 12, 2008 at 9:58 PM
You are right! The OnClick declarations are not in the xml!!!
Why not? I added these methods the same way.
Is this a bug?
Feb 12, 2008 at 10:13 PM
For curiosity's sake I started from scratch and the result was identical.

First I added a FontString field and named it "lblMessage".
Next I added a button and did not rename it.
Then I added a second button.
And a third button.
I double-clicked the first button and added the function text.
Then I did the same for buttons 2 and 3.
When I right-click Frame.xml in the solution explorer and select "View code" the xml shows that the scripts contain the function calls, i.e. Button1OnClick(), Button2OnClick(); and Button3_OnClick.
However, when I build the project and view the output Frame.xml, only the first button has a <scripts> tag.
Of course, if I manually add the scripts all works ok.
So I guess it IS a bug!
Coordinator
Feb 27, 2008 at 3:37 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.