switching pages in pageframe
Author Message
ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 I want to be able to detect when I am clicking on a page tab to switch pages, so I can control which portions of a lostfocus event on an object in the current active page will execute. I appears that I can't use mouseenter on the target page, like I do on command objects. Visual FoxPro2

Tamar E. Granor

 Posted: Visual FoxPro General, switching pages in pageframe Top
 Could you do what you need to in the Page's Deactivate event Tamar

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 No, the object with focus always fires it's lostfocus before the page fires it's deactivate - essentially I need to know why I'm leaving the object before the lostfocus fires, so I can orchestrate the lostfocus code accordingly.

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 Note that, with command objects, I always use mouseenter and mouseleave (which activate irregardless of the focus) to fill and clear a form property with the object name. That way, I always know if I clicked a button or not. The perfect use is skipping validation code imbedded in a lostfocus if I click a button. I can't find a similar capability in a pageframe to track changing the active page.

CetinBasoz

 Posted: Visual FoxPro General, switching pages in pageframe Top
 UIEnable might be what you're looking for

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 Won't work, since the uienable fires when the page is deactivated, which is after the object.lostfocus is fired. I need to be able to find out before or while in the lostfocus, since that is where I put my validation code for the object. The perfect solution would be that mouseenter and mouseleave would work on the tab portion of a page, but that doesn't seem to be the case. Then I could tell if the object is losing focus because I'm navigating to a different page.

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 Ok, I've been trying another tack, albeit a little kludgy - placing invisible commandboxes over the tabs. Problem is, I can't find any combination of placement of commandboxes on pages or screen, with any setting of zorder, that will keep the buttons in the list of active objects. It's sort of like the area of the window taken up by the tabs of a pageframe is a dead-zone for objects, and all mouse events are directed to the current active page. Is there any way to create an object to reside on the same window space as a pageframe tab, that can be kept active Richard

Tamar E. Granor

 Posted: Visual FoxPro General, switching pages in pageframe Top
 What are you doing in LostFocus that requires knowing where you're going Tamar

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 I have validation code in some object's lostfocus - some of which I do not want to execute under certain conditions. For example, if I am clicking a button, I don't want to check to see if a required text field is empty. In this use, I have several pages each dedicated to a particular action, and the "DO IT" command button checks which page is active to know what to do. If I switch pages, I don't want to execute validation code on the page I am leaving (although I will track if validation is done so if I go back later to execute I know whether or not data has been validated). I often put messages up and direct the focus depending on what the validation code finds - not good if the user just wants to switch pages.

CetinBasoz

 Posted: Visual FoxPro General, switching pages in pageframe Top
 You could set tabs to false and place command buttons instead. Actually I didn't undesratnd what you mean, if you place a comandbutton on a pageframe then it's in front of zorder already. I don't think this is a good solution. I also don't understand why mouseenter,mouseleave would be the ideal place. User might simply bypass it not using mouse (if one day you enable keyboard accelarators and boom). I also do not understand why it wouldn't work for you if UIEnable is firing after lostfocus. You can setfocus back, no Maybe you're seeking soemthing like bindeevents() PS: If mouseenter/mouseleave sounds to  \be a solutio to you you can check where mouse is in lostfocus.

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 I agree using command objects isn't the ideal solution - the more kludgy a solution becomes, the less clean the code is, the more obtuse execution becomes - the worse the solution. I was just looking for possible solutions. If I create a command object, in the window but placed over the tabs, once the pageframe is activated I can't get back to the command object (apparently because the pageframe object is covering it), and even if I try to reset zorder in the page activate or the command click events it won't work. If I try to put the command object on a page and slide it up into the tab area, the object gets a (-) location for top, and the command object becomes unavailable. You are right too about the mouseenter and mouseleave not covering using the keyboard to switch objects. I suppose I could test keyboard entry in the keypress event, but this is quickly becoming a maintenance nightmare. I like simple as much as I can manage it. I can't move validation code out of lostfocus either. For the example where a textbox asks for a key value such as customer code, then uses that code to populate other objects on the page, the validation needs to be with the customer code object, so invalid entries can be detected and the user alerted for options, or if the entry is correct the remaining values can be retrieved - right at the time of entry, not later. If UIEnable fires after lostfocus, then how could I use UIEnable to manage lostfocus. In lostfocus I have something like: do case case thisform.nextobj = "thisform.cancel" *-- don't validate case thisform.incommandbuttons *-- amend validation otherwise *-- validate the entry endcase Those values thisform.nextobj, and/or thisform.incommandbuttons have been set in mouseenter, and cleared in mouseleave of various objects on the page or window, knowing that if the mouse is on an object when it is clicked, then the user must have intended to go to that object next. The nice thing about mouseenter ... is that it fires for any object regardless of which object has focus. Therefore I can tell if the user is on the button for example, while the user has focus on a text object, BEFORE the user clicks on the button. I can then use this information in the lostfocus of the text object to control what code gets executed (or not executed). If I wait until the UIEnable event is fired, I'm past the point where I can manage the code in the lostfocus event. At least as far as I know. I'll have to think about how I might be able to use bindevents, I'm not sure if I can or not to get the behavior I'm looking for. Also, using the mouse position to figure out if it is over a tab could work, but it might become very messy if the number of tabs changes interactively, or if the position of the pageframe moves, or also possibly if screen resolution changes, or if the user resizes a window or a container. I'd have to think about it and do some testing. By the way, thanks for helping me on this - I really appreciate it!! Richard

CetinBasoz

 Posted: Visual FoxPro General, switching pages in pageframe Top
 You're welcome. What I still don't understand is if you're managing validation in lostfocus (well I too prefer it over valid) then what does it matter if it is an attempt to change page. You'd still not let it if the content is invalid, no Or you could do it as in old days (when there were a bug in grid controls valid is bypassed when clicked outside) and first let it go (UIEnable) and setfocus back to it if need be.

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 True, validation is still necessary, but only if you go back to that page to use that data. The data is unused and unnecessary on any other page. This particular instance is not one in which data on multiple pages relates to one another. I'm trying to avoid the example where focus goes to a key field on entry to a page, an entry is required for that field (empty is not ok), but the user decides he really didn't want that page after all, and wants to switch to another page, leaving the key field empty - which is invalid. I think the user should be allowed to leave the page (and the field) gracefully if going somewhere where the data in the field doesn't matter (like exiting, or another page). Only if the user returns to the page does the data matter, and I can check validation there when necessary (or blank unvalidated data on return to the page). Nothing can frustrate a user more than a piece of software that doesn't allow the user to do what they want. I can just see the fits of anger when the user goes to leave the page and instead gets a message saying his data is invalid. *&$## I don't care - I'm leaving that page anyways. ##$!%#!!! Stupid F### software! So, yes I would let it go. I'll deal with it if and when the user returns to the page.Of course, if they stay on the page, I want to know that too, because if the lostfocus is fired when the user is staying on the page, then I need immediate validation so I can prompt the user to reenter, or list, etc as needed right when they are leaving that field. After all, I can't fill the remaining fields on a page (say for example a customer page) unless I have valid data to locate a record with etc.

CetinBasoz

 Posted: Visual FoxPro General, switching pages in pageframe Top
 OK, along the lines in previous messages you said mouseenter/leave would somehow work for you. Then you can use pageframe.mouseenter, mouseleave to set a flag to signal lostfocus that it's on tab area, no (and maybe handle kb accelarator with keypress as well).

ILoveOregon

 Posted: Visual FoxPro General, switching pages in pageframe Top
 I think you've hit upon my best solution. In testing I see that the pagframe mouseenter/leave operates in the tab area, whearas the page mouseenter/leave operates in the page proper. If I use the pageframe mouseenter/leave, I can't tell which tab I'm selecting (activepage still points to the actual active page), however I CAN tell that I am on a tab and not the page itself, which should be enough info for this issue I'm facing.It would be a very helpful new property for a pageframe to show which tab (if any) has just been clicked (set prior to firing of any method). As a matter of fact, it would be nice if the idea was expanded to a form property showing the id of the next object selected for activation (by mouse, tab, keyboard etc) - which would be set PRIOR to any methods firing. This would be a simple and easy way to know the direction of focus while still in the last active object. I could see lots of uses for that knowledge.Thanks again for your help.Richard