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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden Mouse Click On Form???? VFP 9 Combobox Problem

Status
Not open for further replies.

networkthis

Programmer
Jul 11, 2011
29
US
Is it possible to do a hidden mouse click on a form, without affecting the position of the mouse itself???

I'm asking this question because we have discoved the following is happening with a lot of our users. Also, I have found a few others on the net having the same issue, just with no resolution to the problem. It seems to only be occuring with VFP 9.

When a user is holding down the left mouse button on the scrollbar generated by a combobox and is scrolling through the options and goes off the scrollbar (while still holding the left mouse button)(*They release the left mouse button outside of the dropdown) - then return to the dropped down list and left click on a value, it will not select and display that value. This selected value is stored by default I believe in the valid event (?) However, the valid and when events are not released when this happens unless you click on the form itself. It is as if the click function is disabled after losing focus on a combo box while scrolling.

So, here are my thoughts: I can make this problem go away by simply adding MOUSE CLICK in the mouseleave event. This works wonderful, as long as your combobox is no where near any other object :-/ So, I tried making the MOUSE CLICK at 1,1 and hiding with mousepointer = 13. This works great for displaying the value correctly everytime. Yet, it's not practical to move the cursor on the user everytime. I can get the current X and Y coordinates on the mouseleave, but when I try to make the mouse coordinates return to those coordinates on the form itself... I can not for the life of me figure it out... MOUSE CLICK wants a "WINDOW" name and I'm lost as the form itself isn't a window?? There has to be a way to do this. I almost just need an invisible click at 1,1 and then immediate return to where the mouse was, or a better idea! I'm still new at VFP and any help is greatly appreciated!!!
 
i'm not seeing the behaviour you describe....

what code do you have in any events on this combobox?

try putting set coverage on and seeing what events fire and what code gets executed when you recreate the problem

VFP9 SP2 ?

Nigel



 
I can sort of see this behaviour. When I do as you describe, it's true that the item you left-click on doesn't become selected. (You can demonstrate it by adding code to the combo's InteractiveChange; have the code display the combo's .Value in a label.)

But I don't see it as a big problem. The point is that the combo will continue to display the selected value. It might not be the value the user wants, but it is completely obvious to the user which values is selected, and it only takes another click or two to put it right.

On the other hand, the behaviour does seem to be specific to VFP 9.0. So it's not something a user would reasonably expect. So, I suppose for that reason, it should be fixed.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
To answer your original question, you say:

MOUSE CLICK wants a "WINDOW" name and I'm lost as the form itself isn't a window??

Actually, a form is a window. And the form's Name property is the window name that the MOUSE command requires.

So if your form's Name property is set to MyForm, you want this command:

Code:
MOUSE CLICK AT 1,1 WINDOW "MyForm"
   && Note the quotes around the form name

That will click the mouse in the top-left corner of the form.

Don't forget that the X,Y co-ordinates are measured in characters, not in pixels as is usually the case with forms.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks for the responses so far everyone.... Here is some sample code so that you can see what I am saying that it is doing: Try it like this first. I have it displaying the different events directly to the screen as they fire so that you can hopefully see exactly what I am.

Mike, I forgot to mention above that interactive change does not run either when this is happening... as you should be able to see with this, but it also fires when you click the form after the drop down is closed.

Also, I tried the MOUSE CLICK AT 1,1 WINDOW "Form" and it works. Thanks! Is there a way to make that occur without seeing the mouse actually move?

Also if you have tried it like that and are seeing the problem, then you can try it with the MOUSE CLICK event uncommented under the mouseleave procedure and all the events fire as if everything worked properly....


CLEAR

*SET STEP ON

SET COVERAGE TO "C:\Documents and Settings\dhscn23.DHSNTDOM01\Desktop\errors.log"
DIMENSION gaMyComboArray(100)

FOR gnCount = 1 to 100 && Fill the array with letters

STORE REPLICATE(CHR(gnCount+64),24) TO gaMyComboArray(gnCount)

NEXT

frmMyForm = CREATEOBJECT('Form') && Create a Form
frmMyForm.Closable = .f. && Disable the Control menu box
frmMyForm.Move(150,10) && Move the form

frmMyForm.AddObject('cmbCommand1','cmdMyCmdBtn') && Add "Quit" Command button
frmMyForm.AddObject('lstComboBox1','lstMyComboBox') && Add ComboBox control
frmMyForm.AddObject('lstListBox1','lstMyListBox') && Add ListBox control

frmMyForm.lstComboBox1.RowSourceType = 5 && Specifies an array
frmMyForm.lstComboBox1.RowSource = 'gaMyComboArray' && Array containing Combobox items
frmMyForm.lstListBox1.RowSourceType = 5 && Specifies an array
frmMyForm.lstListBox1.RowSource = 'gaMyComboArray' && Array containing Listbox items

frmMyForm.cmbCommand1.Visible =.T. && "Quit" Command button visible
frmMyForm.lstComboBox1.Visible =.T. && "Combo Box visible
frmMyForm.lstListBox1.Visible =.F. && "List Box visible

frmMyForm.SHOW && Display the form

READ EVENTS && Start event processing

DEFINE CLASS cmdMyCmdBtn AS CommandButton && Create Command button
Caption = '\<Quit' && Caption on the Command button
Cancel = .T. && Default Cancel Command button (Esc)
Left = 10 && Command button column
Top = 60 && Command button row
Height = 25 && Command button height


PROCEDURE Click
CLEAR EVENTS && Stop event processing, close Form
CLEAR && Clear main Visual FoxPro window
ENDDEFINE


DEFINE CLASS lstMyComboBox AS ComboBox && Create ComboBox control
Left = 10 && Combo Box column
Top = 10 && Combo Box row
MultiSelect = .T. && Allow selecting more than 1 item

PROCEDURE Click
ACTIVATE SCREEN
CLEAR

? "Selected items:"
? "---------------"

FOR nCnt = 1 TO ThisForm.lstComboBox1.listcount
IF ThisForm.lstComboBox1.Selected(nCnt) && Is item selected?
? SPACE(5) + ThisForm.lstComboBox1.list(nCnt) && Show item
ENDIF
ENDFOR

PROCEDURE gotfocus
ACTIVATE SCREEN
?'got focus'

PROCEDURE when
ACTIVATE SCREEN
?'when'

PROCEDURE valid
ACTIVATE SCREEN
?'valid'

PROCEDURE interactivechange
ACTIVATE SCREEN
?'interactive change'
?frmMyForm.lstComboBox1.value

PROCEDURE lostfocus
ACTIVATE SCREEN
?'lost focus'

PROCEDURE click
ACTIVATE SCREEN
?'click'

PROCEDURE mouseleave
LPARAMETERS nButton, nShift, nXCoord, nYCoord
ACTIVATE SCREEN

*Uncomment Mouse Click and the selected value will display in the combo box
*MOUSE CLICK

ENDDEFINE

DEFINE CLASS lstMyListBox AS ListBox && Create ComboBox control
Left = 120 && Combo Box column
Top = 10 && Combo Box row
ENDDEFINE
 
Mike, guys, this (or some vestige of it) is in earlier versions as well, although it's actually easier to repro in a listbox.

Press the mouse button on one value in the list, and drag to another value in the list before releasing. The new value is selected but .Valid and .InteractiveChange do not fire even though the .Value definitely changed and it was obviously interactive. Something definitely goes off the ranch in the event method sequence.

(As I said, it has had many variations through the years.)

IIRC, you can work around the problem in .MouseUP() (but I don't remember what I did).

It's a weird problem with a kludge resolution. <shrug>
 
Also, I tried the MOUSE CLICK AT 1,1 WINDOW "Form" and it works. Thanks! Is there a way to make that occur without seeing the mouse actually move?

Does it make it any difference if you do KEYBOARD '{LEFTMOUSE}' instead of MOUSE CLICK?

And how about RAISEEVENT()?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
I tried the KEYBOARD '{LEFTMOUSE}' as well as the win32 #Define VK_LBUTTON 0X02 and had no luck with either. I was unsure how to make either of those events occur at 1,1 on the form though.

I also tried RAISEEVENT() with the combobox. This is something I was unaware of and I see it being very useful in the future, but it didn't work here unfortunately.

I do have another idea though. Maybe I've been going about this wrong. Is it possible to just make the drop down from the combo box close once the mouse has actually left the (drop down) area???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top