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

Checkbox mystery

Status
Not open for further replies.

Phil Thoms

Programmer
Oct 31, 2005
245
GB
I have a form with a grid containing data and a checkbox. All works well except that sometimes when you pass the cursor over the checkbox without clicking, a selection (or de-selection) can be made. Is this a fault in VFP6 or is there a property which I can use to cure this?
Thanks
 
Where did you get your checkbox from? Is it possible it has code associated with the mouseover event?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
As with Griff, the MouseOver occurred to me as well.

I suggest you do the following:

1. Select the checkbox in the properties window.

2. Right-click above the tabs in the properties window, and select Non-Default Properties Only.

3. Scan down the list of properties and methods, looking for any setting which you were not expecting or which you cannot explain. In the case of methods, open the code editing window to see what code is being executed.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Also notice entering SPACE equals a CLICK, when a control has focus.

Do you set sparse=.F. to see the checkbox in each row - also non active rows - with its value? Is the checkbox bound to a boolean? Nullable? Checkboxes work with .T./.F./.NULL. and also 0,1,2, that would not change mouseover behaviour, so Griff and Mike surely are on the better track, but I also remember VFP (not only version 6) would show a control in a grid, even though it's not set visible=.t. and you got strange effects from that alone.

Bye, Olaf.
 
Some people like the mouseover to select/deselect the tick boxes in a grid - it can give the appearance of multiple records being selected without masses of clicks

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hello,
Thanks for all your replies.
I've used Mike's suggestion and found that the following code is in the in the click event:-

DODEFAULT()
KEYBOARD '(DOWNARROW)'

Also Olaf asked about the sparse property setting which is already set to .F.

Thanks



 
... found that the following code is in the in the click event:-

DODEFAULT()
KEYBOARD '(DOWNARROW)'

That's interesting. Have you tried removing that code? If so, does the problem go away?

It seems unlikely that that is the cause of the problem, given that you say the code is in the Click event, but the behaviour you are seeing occurs when you mouse over the control.

Also, the fact that you didn't know about that code suggests that someone else created the grid (or the checkbox). Perhaps you based your own grid on someone else's class. There's nothing wrong with that, but you do need to examine the class very carefully when you do that, precisely to avoid this kind of unexpected behaviour.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
DODEFAULT() points out there is a parent class which also has click code. And as you have mouseover behaviour the code for that might also be in the parent class. You won't see that on the level you are. In VFP9 you have the "View Parent Code" button, in earlier versions you'd need to install Ken Levys Superclass utility (
Besides that there can be BINDEVENT calls to bind to events and handle them elsewhere, too. KEYBOARD '{DOWNARROW}' can let whatever behaviour happen to the next row.

You could set a breakpoint reacting to the modification of the bool field bound to the checkbox and then see what code does it.
breakpoint_u4tjoj.png

From there it should be easier to find out what happens, looking at the callstack window and clicking where the code running was called from.

Bye, Olaf.
 
Thanks Mike and Olaf.
I have been using this form for about a year which I created and now remember putting this code in myself from a tip from here(I think) for when I selected the record at the bottom of the grid I wanted it to go to the next record automatically if there is one and it works. Hope this is clear.
 
Mike,
Sorry got disturbed before I could test.
I removed the code and all seems well. However, Olaf mentioned that using the space bar can select or de-select which also happens BUT he was getting my the original problem without the code I assume.
May be that the space-bar error can be easily cured?

Thanks
 
Well, I'm not sure I'd call it an error, but if you want to prevent the spacebar from selecting the checkbox, then you could try this code in the Keypress of the checkbox:

Code:
IF nKeyCode = 32
  NODEFAULT
ENDIF

But I'm not sure if that will help solve the original problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>now remember putting this code in myself from a tip from here(I think) for when I selected the record at the bottom of the grid I wanted it to go to the next record automatically
Well, that would need this code only in the last row, but as the grid has all column controls only once and isn't really a collection of row times these controls, you can't have [tt]KEYBOARD '{DOWNARROW}'[/tt] only in the last row, this would happen in all rows.

Also it will need to be with curly brackets, otherwise you would put the whole world [tt](DOWNARROW)[/tt] including brackets on the keyboard buffer. Only some keywords in curly brackets make the KEYBOARD command put special control keys on the keyboard buffer.

Bye, Olaf.
 
Thanks Olaf and Mike,
I'll try what you suggest and let you know asap.
 
The spacebar problem is now cured.
Just to clarify that I did use curly brackets in the actual command, I typed the wrong brackets when explaining in this query.

Many thanks
 
The spacebar problem is now cured.

Delighted to hear it, and thanks for letting us know.

But I'm still not clear as to whether you have solved your original problem ("sometimes when you pass the cursor over the checkbox without clicking, a selection (or de-selection) can be made").

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
The original problem now seems OK, I will indeed keep you informed in case it re-appears.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top