Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code jumping from Setfocus to Lostfocus
Message
From
20/07/1999 18:17:45
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Code jumping from Setfocus to Lostfocus
Miscellaneous
Thread ID:
00243887
Message ID:
00243887
Views:
60
Here's the problem...
Created a commondgroup class with a lostfocus event.

Referred each command button's lostfocus event to the parent lostfocus.

The object of the lostfocus was to set a variable off. The variable is set on as soon as the commandgroup or its buttons receive focus.

It works in one (and a half) direction only. i.e. if the user selects anything other than the commandgroup, the lostfocus event fires and sets the variable off.

It also works if I then click a command button because I also reset the variable as part of the click method.

However, I also have a keypress trap for the PGDN key which sets focus to the 'Command1' button of the commandgroup. This too works - and correctly fires the command button's setfocus which sets the required variable back on and refreshes the commandgroup. So far so good.

The trouble follows immediately. The code now moves directly on without a pause to the button's lostfocus, which, as I said earlier, fires the parent lostfocus and switches the damn variable back off again! Yet the command button is still visibly 'selected' and thus should not have lost focus.

I have kludged around it by inserting a timer and if the lostfocus gets called in less than a quarter of a second I ignore it. That makes the whole thing work but what an ugly way to have to do it!

The code following the setfocus sets the variable on and then refreshes the form. Is it the refresh thats causing the loss of focus and is there a cure? The refresh is necessary, btw, as the point of the variable is to set the background color of the commandgroup. (The idea is to give a visual cue to which part of the screen is 'in control')

Any illuminations?

Harry
Next
Reply
Map
View

Click here to load this message in the networking platform