Suggestion: GUI ControlType property (SOLVED)

Started by RickJ, Thu 10/03/2005 06:57:01

Previous topic - Next topic

RickJ

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?


Rui 'Trovatore' Pires

I don't suppose you could work around it with the "AsButton" and such commands...?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

RickJ

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.   

Pumaman

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.

RickJ

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

SSH

Maybe you were thinking CJ would be adding switch/case constructs to the AGS langauge  :=
12

SMF spam blocked by CleanTalk