Page 1 of 1
is there a way to point CMlControl by Ident on a CMlPage ?
Posted: 09 Dec 2017, 18:11
by reaby
Hi,
I would like to find CMlControl in CMlPage by Ident... is it posssible a fast way ?
Re: is there a way to point CMlControl by Ident on a CMlPage ?
Posted: 09 Dec 2017, 18:16
by reaby
I think using Classes as indexes doesn't work out good...
declare Integer[CMlLabel] for Page = Integer[CMlLabel];
Code: Select all
Void TriggerConfirmButtonClick(CMlLabel Control) {
log(Control); // Control = CMlLabel#1234
if (Control.Parent.HasClass("uiButton")) {
if (pendingConfirmIds.existskey(Control.Id) == False) {
pendingConfirmIds[Control.Id] = Control.Value;
pendingConfirms[Control] = Now; // Control = CMlLabel#Null
}
}
....
So best way to fix this would be to point control by ident

Re: is there a way to point CMlControl by Ident on a CMlPage ?
Posted: 09 Dec 2017, 19:01
by reaby
ok Answering myself, fixed by adding
Code: Select all
declare CMlLabel[Ident] pendingConfirmControls for Page = CMlLabel[Ident];
pendingConfirmControls[Control.Id] = Control;
It kinda looks stupid on code side when there's 3 variables doing "same" thingy... but it works.
Re: is there a way to point CMlControl by Ident on a CMlPage ?
Posted: 10 Dec 2017, 11:10
by zocka
(You are not trying to use classes as index values but objects (= instances of classes).)
Using objects as index values should work (as the array-key hashing probably already works on the idents).
I can't reconstruct and don't understand your problem from what you are providing.
As you probably are only concerned for a certain set of controls to find by ident (say elements with a certain class), you could initially build yourself a map with ident=>control. Keep in mind that you would probably want each element from your GetClassChildren_Result in a temporary variable to not accidently lose track of it along the way.
From the snippets you provided I don't see why you would need so many arrays. If you keep track of the controls themselves, you don't need to store e.g. the Label's text alongside as you can access it from the control anyway. In the same way you can declare additional variables like this Now-value for the control.
Re: is there a way to point CMlControl by Ident on a CMlPage ?
Posted: 11 Dec 2017, 20:11
by reaby
thanks!