Peter K. Stys, MD wrote:
>I have an array of checkboxes, I want the clicked one to look checked
>(like a radio button group, but I want checkboxes):
>
>Sub Action(index as Integer)
> dim j as integer
>
> ' clear all but the index checkbox
> for j = 0 to 3
> if (j = index) then
> self.CheckBox1(j).value = true
> else
> self.CheckBox1(j).value = false
> end if
> next
>
> Return
>End Sub
>
>You'd think this would be a no-brainer but it doesn't work because the
>self.CheckBox1(j).value = true/false stmnts fire new Action events in
>the other (jth) checkboxes so everything gets screwed up.
>
>I think firing events in response to control changes in done in code
>is a dumb idea. Action is a user action, not a program's execution.
>If I'm explicitly doing self.CheckBox1(j).value = true I don't need to
>be told that I've just done this by having a new event fired!
>
>Ditto for TextChanged events in editfields, etc...
>
>There should be an easy way to tell whether an "event" was triggered
>by the user vs. code.
>
>Don't others agree?
>
>P.
Well, what I do in these situations, and I do it a lot:
Define a boolean property for the window containing the control (
meActive default = False)
In the Controls MouseDown event; meActive = True
in the Controls Action event:
If meActive Then
meActive = False
// do your thing .....
end if
This way only if you clicked on the control your action code will be
executed. It's not foolproof but works quite well. If you want to
be foolproof, in the Lost Focus event set meActive = False just in
case the Action event was not triggered.
HTH
--
Cheers,
Peter
TI PowerBook G4, 1GHz, 1GB RAM, OSX 10.3.9, RB2007r1 Pro
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>