Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox valid/lostfocus fires before interactivechange?
Message
 
 
To
31/01/2019 14:07:45
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 10
Miscellaneous
Thread ID:
01665845
Message ID:
01665851
Views:
79
>>Maybe this has never mattered before, but I haven't noticed it until now:
>>
>>I had code in the lostfocus method to add what a user typed into the dropdown list dynamically using additem(). This worked great until I added some code into the valid for this class. As I've been debugging, I noticed that typed information now gets wiped out when leaving the field. I tried adding some debugging code into the interactivechange to see if I could use additem there. When I step through the code, it appears that the interactivechange method begins to fire, but the valid takes over, then the lostfocus, then finally gets back to the interactivechange. Worse, after the valid finishes, the displayvalue for the control is blanked and consequently, so becomes the value, thus blanking the control, so there is nothing there for additem().
>>
>>However, as far as I can see, when I set coverage logging on, it appears to log what I expect (simply runs interactive change until moving out of the control, but the control still blanks out. What would cause the control to lose focus during an interactive change?
>>
>>I had a keypress event in the form, which I suspected was causing trouble. I've taken that out and still have the same behavior.
>>
>>if I have no code in the valid, then the lostfocus has a this.displayvalue and the text is added to the list and still displays in the control. Adding anything to the valid breaks this behavior. What in the world am I missing? Any advice would be greatly appreciated!
>
>Is the combobox control in question based on the built-in combobox control, or is it based on a subclass? If the latter than adding code to VALID may be overriding code within the class definition (i.e. you may need to call DODEFAULT() to make sure original code in the class to be executed).
>One other thing you might have to be careful are situations where code that stuffs keystrokes into the keyboard buffer.

Thanks for your reply - you got me thinking of making this the simplest setup possible, for testing.

I just tried with a base class combobox on a new form and got the same behavior: if I put code both in valid and lostfocus, there will be no displayvalue in the lostfocus method. if valid is empty, then lostfocus has a display value. This seems so basic - if I put this.additem() into the valid, nothing happens. my rowsourcetype is 1 (value) - I could try to change this, but I literally have 120 of these guys on a form that has been running for years...not something easily changed. What's the easiest way around this limitation?

To recreate my test:
drop a combobox on a new form. Set controlsource to some table, field1 (character c(10) or whatever)
set the rowsourcetype to 1
put "A,B,C,D" in rowsource

put in lostfocus:
this.additem(this.displayvalue)
If you just do this and run the form, typing "123" or whatever in the box and hitting tab will keep the 123 and add it to the dropdown combo.

if you put anything in the valid, such as x=1, and rerun, then the box will blank out when you hit tab. the control's displayvalue will blank as soon as it exits the valid. Also, issuing this.additem(this.displayvalue) in the valid doesn't seem to add the line to the rowsource, even though the displayvalue does still show in the valid.

Is this expected behavior? a bug? I feel truly dense right now that this doesn't work...
Steve Howie, owner
DaSH Technology
Denver, CO
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform