Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code jumping from Setfocus to Lostfocus
Message
 
 
To
20/07/1999 18:17:45
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00243887
Message ID:
00243943
Views:
18
So you have KeyPress code that sets focus to the first command button of your group. If that is all you want the KeyPress code to do, try adding NODEFAULT as the last command in that KeyPress Code. That should leave the focus on the command button. If that does not help, you should probably post your KeyPress code, and where this code is located, what code is doing the form refresh, etc. Most of this depends on where the actual commands are in relation to the rest. In command buttons [and other controls], you can finish off the code with a RETURN 0 [that is a ZERO returned] which leaves focus on the current control.

>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
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform