Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: RickJ on Thu 10/03/2005 06:57:01

Title: Suggestion: GUI ControlType property (SOLVED)
Post by: RickJ on Thu 10/03/2005 06:57:01
I recently came across the need to determine what kind of control, to which a GUIcontrol pointer points, while trying out the new V2.7 GUI stuff.   

I am making a generic GUI click handler where I pass the control pointer and mouse button to the handler.  To handle the click it's necessary to extract text from the control, however, it is necessary to know what kind of control it is.  For example, you would use GetText if it were a button and GetItemText if it were a listbox.

So I wonder if it would be reasonable to add a ControlType property to GUI controls in some future version of AGS?

Title: Re: Suggestion: GUI ControlType property
Post by: Rui 'Trovatore' Pires on Thu 10/03/2005 10:37:24
I don't suppose you could work around it with the "AsButton" and such commands...?
Title: Re: Suggestion: GUI ControlType property
Post by: RickJ on Thu 10/03/2005 15:34:58
I guess you could do that by walking through each of the possibilities and testring for null.  Not quit as clean as having a property though.   
Title: Re: Suggestion: GUI ControlType property
Post by: Pumaman on Thu 10/03/2005 20:43:49
Yes, testing the AsXXXX for null would be the way to do it.

I'm not sure what exactly you'd expect a ControlType property to return. If it was a string containing "Button" or "Listbox" or whatever, that gives you no advantage over simply doing:

if (control.AsButton != null) {
  control.AsButton.GetText(buffer);
}
else if (control.AsListBox != null) {
  control.AsListBox.GetItemText(buffer);
}

type stuff.
Title: Re: Suggestion: GUI ControlType property
Post by: RickJ on Thu 10/03/2005 21:28:09
I agree there is little advantage in returning a string and that hadn't even occured to me.   I was, of course, thinking it would return an enum such as eListBox, eButton, etc.  I'm sorry if I wasn't clear about that.

Hehe, But now that I see your example it is clearly the same thing I would have done with a ControlType property.  There would be no advantage in that either.  What could I have been thinking?  As Homer Simpson would say "Doh!".   :-[

Cheers
Title: Re: Suggestion: GUI ControlType property (SOLVED)
Post by: SSH on Fri 11/03/2005 10:59:33
Maybe you were thinking CJ would be adding switch/case constructs to the AGS langauge  :=