Peter K. Stys, MD wrote:
>I do this too...and, like you, I do it a lot. That was my point: does
>your program need to be told that it just modified the state/contents
>of a control?
Well, it depends on the control. For CheckBoxes for example where
there is only an Action event, it's quite simple. I sub-class
EditFields where I trigger an "EndAction" event whenever I see a
Tab-, Enter-, or Return key. I also add a bunch Asynch Control key
detections and fire a special event when any of those are
encountered. For ListBoxes I have a family of sub-classes depending
of how I want the User to interact there.
>
>For editFields, I suggested a while back a new event 'UserTextChanged'
>that would fire if the user, not the program, changed the text,
>eliminating the need for these gymnastics that I'm sure all of us have
>to do. This could be generalized to many/all controls.
For the sub-classed EditFields I have a boolean in the sub-class that
can be set at design time. For example, if I see a TextChange after a
KeyDown event or a LostFocus, depending on this Boolean, I trigger my
"EndAction" event. For windows with lots of EditFields for the user
to enter data, this comes in quite handy. Now, I'm sure that my
implementation is not the slickest and probably can be improved, but
it works quite well. I do a lot of pre-loading these EditFields when
reading back existing data files. So, the various action events have
to be made dependant on user inputs. In most cases I use the
MouseDown event for this.
--
Cheers,
Peter
>On 3/8/07, Peter E. Barck <[EMAIL PROTECTED]> wrote:
> > 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>