Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down List (Changing Focus From)

Status
Not open for further replies.

CDavis

Programmer
May 5, 2000
155
US
For this question, I'm using VFP 3.0

I've created a dropdown list object that contains department numbers. The initial value is set to the current record value. After the enduser interacts with the dropdown list, I want to set the focus to another object (in this case a textbox named Requestor).

I've placed the following code in the interactive change event of the dropdown list object:

ThisForm.Requestor.SetFocus

This works as expected when the user chooses a new value from the list. However if the user doesn't find a new value that is appropriate and closes the dropdown list by selecting the current value, the focus remains with the dropdown list. I've tried several different events and I'm almost convinced that what I want to do is not possible. I'd like the focus to change anytime the dropdown is opened and then subsequently closes --

Any suggestions??
 
The book I've got on VFP 3 shows a DropDown event and says it occurs for either a combo or list box, though another table only shows in in the combo box. Anyway, if it does exist for your box, I'd suggest a two step process. First in the DropDown event set some variable to indicate that a dropdown is occuring and then in the click event of the box check for the value of this variable to see if this box was dropped down and now needs to move on. Of course I'm not sure what to do about scrolling since I assume that will fire the click event too. Perhaps you have to actually measure where the click occurs to see if the user is giving up or wants to see more of the list. --Dave
 
Put the code
ThisForm.Requestor.SetFocus
in the LostFocus Event instead of teh interactive change event. ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Ramani,

How does putting the code in the lost focus event help? His whole problem is that the box doesn't lose focus. Or am I missing something?

Dave Dardinger
 
The InteractiveChange event is not being triggered because the value isn't being changed. Put the code in the Valid event.

Jim
 
I'm still confused. If you click on the current value (indicating you couldn't find another value you wanted), you aren't going to fire the valid event are you? (And that's an actual question as I don't know what happends in this case.)

OTOH, I notice that even in VFP6 you don't have a dropdown listbox, just a dropdown combo box, so I assume that's what existed in VFP3 as well.

Dave Dardinger
 
Thanks for the suggestions. As some of you have noted the lost focus event is not occuring and neither is the valid event because that should happen just before lostfocus.

The dropdown list is just the style of the combobox. (It doesn't allow entering of text). I suppose I could write code in each event that potentially could happen and do some testing to see if the user really wants to leave the object. But that seems pretty convoluted. Its too bad that I can't access the event that must be happening when the dropdown ends.

If someone thinks of something creative, let me know.

 
Oh yes, I misunderstood the question. Lost Focus event, Valid Event, INteractive change event wont get fired under the circumstances, when the change is not taking place.
(DEDMOD is right.. Thanks for pointing.)

In this situation,
The Click event and The InteractiveChange event can have the code.... ThisForm.Requestor.SetFocus

Sine it is a dropdown list, clicking to close the dropdown would amount to firing the click event.
Any Tab or enter key pressing will fire interactive change event.

Hope this solves the problem

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Its too bad that I can't access the event that must be happening when the dropdown ends.

I suspect that it's just a 'click' event. Presumably there's buried in the base class click event a way of checking where the user clicked and reacting appropriately. But of course you can't access that code. So you have to reproduce it if you want to add the desired functuality.

But this brings up a question. Is there a class out there, on the Universal Thread, for example, which has the functuality you want? A little searching may pay dividends!

Dave Dardinger
 
Thanks again for all the helpful suggestions.

I've been able to develop a work around.

In the init event of the form I've created a public variable mDrop and initialized it .f.

In the dropdown event I set mDrop = .t.

Then I test for this condition in various other events like Click and if .t. I set focus to the appropriate object. This seems to work okay because the dropdown list doesn't have scrollbars. Maybe they will appear if the list gets too long -- I haven't tested for that -- it would probably be a problem.

Anyway thanks for the help and if any of you have other comments I'll be listening.

-- cd.
 
Yes, scrollbars was what gave me pause in the whole thing. Then you have to determine exactly what the mouse location is when it clicks and keep track of where your scroll bars are; not much fun I expect. Though once you did it and created a new tab-able dropdown, you'd have it for later use. --Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top