Hot Topic (More than 10 Replies) Double focus when Subforms are used (Read 2111 times)
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Double focus when Subforms are used
Apr 10th, 2004 at 6:47pm
Print Post Print Post  
I would like to request, if possible, that there be only one element at time to hold focus. When using subforms, it is possible to have two elements holding focus; one in the main form and one in the subform.

Even though an element on the main form shows a focus box around it, the last element I was in within the subform also has focus, but it doesn't display a box around it.

The problem I am having with this is that On Element Entry programming for the subform is executing each time I advance the main record, even though I have clicked on the main form before advancing.

If I have put focus on an element in the main form, shouldn't focus be there ONLY, and not in any of the subform fields?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #1 - Apr 10th, 2004 at 7:18pm
Print Post Print Post  
Carl,

Both cannot have focus at one time - there may be a bug in the highlighting. If you type where do the keys typed appear? I'll look into the programming issue. Does the programming in the on element entry run if you have never had focus in the subform? I suspect it is running because the on form entry runs on advance/retreat. Is theree any other programming - anything using ThrowFocus, goto, CNEXT, etc...?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Double focus when Subforms are used
Reply #2 - Apr 11th, 2004 at 4:08am
Print Post Print Post  
Quote:
Both cannot have focus at one time - there may be a bug in the highlighting.

What I mean by both having focus is, if I place focus in a subform element, the main form still has a dotted-line box around one element (the one that the cursor was in before I moved to the subform). And if I have the cursor in the main form, the subform On Element Entry programming executes when I advance to the next main record, indicating that focus must be in the subform as well at the same time.

BTW, the subform only leaves the dotted-line box around the element if the cursor was in the element as I moved to the main form. If it was just highlighted in gray, there is no indication that the subform element has any focus.

Quote:
Does the programming in the on element entry run if you have never had focus in the subform?

Yes, if it is the programming for the first element in the subform. If it is for another element, then it only executes if I was in that other element last, just before moving back to the main form.

Quote:
I suspect it is running because the on form entry runs on advance/retreat. Is theree any other programming - anything using ThrowFocus, goto, CNEXT, etc...?

The programming that is executing is in "[ElementName] :: On Element Entry".
There is no other programming. I made a copy of the original application, and removed all other code from both the main form and the subform. The only code resides in the first subform element and the third subform element. It is as follows:

Date1 :: On Element Entry
Amount = "1"

Notes :: On Element Entry
if Notes = "" then
     Notes = @userselect( @XListValues(@fn,"DBS Notes Form!Notes") )

Mark, if you need me to, I can send you a copy of the test application.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Double focus when Subforms are used
Reply #3 - Apr 11th, 2004 at 5:36am
Print Post Print Post  
Mark,

Forgot to mention that I have worked around this by placing a goto command in "[FormName] :: On Form Exit" that moves focus to an element without any programming in it.

(This way, at least the userselect list won't keep popping up when I don't want it to. It now only comes up when I actually move to the Notes element.)

But I still think that this needs looking into. If you move out of the subform, no subform on entry programming should execute as you advance to the next main form record. What do you think?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #4 - Apr 11th, 2004 at 12:57pm
Print Post Print Post  
Quote:
Mark,

If you move out of the subform, no subform on entry programming should execute as you advance to the next main form record. What do you think?


The role of events and subforms has been the subject of a lot of debate around these parts. I've even met those that want it to work one way in one application and an entirely different way in another.

I am aiming for consistency (a difficult goal while some want us like their favorite Windows app and others want us *just like Q&A*). I want the subform to act as though not different from a parent form - so it never needs to know it isn't "just another form". This is especially trying in a table view form, in that each row has the same "data status" as an entire form - yet from a GUI perspective the entire thing is a single widget.


  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Double focus when Subforms are used
Reply #5 - Apr 11th, 2004 at 6:52pm
Print Post Print Post  
Quote:
I want the subform to act as though not different from a parent form...

If I understand correctly, you want the subform elements to act like they are actually just in the parent record, and not from another database.

Assuming that's right, that's why I was surprised that BOTH the main form and the subform On Entry events execute at the same time. I think only the element that the cursor is in, should activate on entry.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #6 - Apr 12th, 2004 at 1:41pm
Print Post Print Post  
Quote:
If I understand correctly, you want the subform elements to act like they are actually just in the parent record, and not from another database.


No, I want the subform to act as though it is a parent. The cleanest, most supportable code, would never "know" that it is a subform - just that is a form. To an extent, we've managed this. The form view subforms not only share the same code with main forms, but are the same code as main forms. There are a handful of exceptions, where a form has to ask itself if it is "parented" - but only a few.

The table view subforms - on the other hand, are not so consistent. This is due to the relationship between a table and a record. Each row represents a record. That means that even very simple navigation in a table view subform can and must generate a large number of events - and communicate with the engine (on the server).

What is important to understand, though, is that this is not a case of dual focus. It is a case of "enter" events running or not.. When a main form is advanced, that qualifies as a "form enter" - little debate. That the focus goes to the appropriate LE when the form advances and causes an LE enter, again - is not widely debated. Because it is the same code as a main form, the subforms also get an enter event while Sesame recursively updates the main and its subs. If we then prevented the LE enter in the subform, we would be inconsistent and the main forms would act different;ly from the subform. This may be convenient, but it is also less predictable - in that same form at different "levels" acts differently depending on that level.

That is really the issue of debate, and has been hotly debated among the developers (and even within this developer). For example - if the main form view form runs form event on advance, then to be consistent, shouldn't each row of the table (as they are the data equal of a single form: one record) also run form enter?

I originally set up the system so that enter and exit event were driven entirely by true focus. But the Q&A community found this to be insufficient. For example - there are several ways to advance a form that don't involve entering the form - such as using the record counter or the command tree. That would allow a form to advance without the form enter event running. The beautiful simple rule - that an enter (real actual, user goes in a form/LE) causes an enter event - did not please the Q&A event advocates. On the other hand, that kind of simplicity has a great deal of appeal in the clarity and predictability of its statement.

But, again for example, using a strict focus model - would also cause the form enter to run if you moused to another application and back into Sesame - on the same form.

So I ended up asking myself a lot of questions: what should happen if the user moves from the command tree to a form they have already been on? What happens if they move from a main form to a subform on that main form? What happens if they move back to the main form from the subform? What happens if they advance the main form, and thereby advance the sub-sub-sub-form? Etc.. Then I looked at the events coming in from the actual GUI, the windows and widgets, and tried to reconcile the several hundred possible events with the several thousand possible navigational cases.

I am not trying to offer excuses, and we will do what we can to remedy any anomalies found - but, I would recommend that whenever programming in any GUI environment (not just Sesame), that you adopt the practice of "state programming". That means you check and maintain the state of your data - as opposed to reacting to the user or events.

The reasoning behind this is obvious if you have an especially "twitchy" user, who, without regard, clicks on fields repetitively and unpredicatbly with the mouse, or taps on PgUp / PgDn nervously. Or, worse, presses F9 / F10 over and over again - for fun.

In any GUI environment, the user has a random access device - the mouse. Even in Q&A, you can use a "goto" and attempt to lock the user into a field - but the mouse will always let them out. And the more extreme the attempt to control the user, the further they will go to extremes to do what they think they want to do, even if it is not the right thing to do. The more extreme the actions of the user, the more likely they are to make extreme mistakes. One of the most common examples of this is the "strict phone number" template. If a designer deploys the usual ten digit template (###) ###-####, it is only a matter of time before extensions and international numbers start showing up in other fields.

In "state programming" the designer attempts to react to changes in the data, as opposed to the actions of the user. Lets say for example that you want to increment a value when the user enters a particular LE. But, you know that the user may and will enter that field repetively. If you simply put the increment in the LE enter event, the number will increment without control. But if you protect that increment with a global static variable that indicates that the number has been incremented already (its "state" transitions from unincremented to incremented), then no harm done. You can also then "protect" that LE by saving that number from edits after it has been incremented. That state flag, typically gets cleared when the number is used in calculation. Again, typically, the number, nor the flag are retained.

In state programming the form or forms and each LE (the data as a whole) maintains its "state". It then can transition from any single state to another state - but only after a minimum set of conditions have been met in the data. The designer can make clear the "state" of the data to the user through visual cueing (color, label, position, size, messages, etc...). Each state then enables or allows particular actions to take place, which - in turn, allow the next change of state.

I'm not sure if I've explained this well and I guess I should apologise for blathering on, but it is actually always much simpler than it sounds when explained, and is one of those things that is easier done than said.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Double focus when Subforms are used
Reply #7 - Apr 12th, 2004 at 2:14pm
Print Post Print Post  
Mark, I am trying to understand your explanation and difficulties you are facing at your level to be consistent and yet accomodative to the needs and demands of the users.  While working with double subforms, one in tableview and the same in the formview, I noted that when you click a record in tableview and then go into the same record in the formview subform, the record will be locked. Theoretically you have moved out of the tableview subform when you have moved to formview subform, so you could not be editing the record in tableview subform. So, how can you explain the locking of the record who had last focus in the tableview subform?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #8 - Apr 12th, 2004 at 2:27pm
Print Post Print Post  
Actually unrelated. The engine (server) side does all the locking and unlocking. It has no knowlege of the user interface or focus. It may be that the server is sending the "lock" message and any form that has that record is locking. The table may have failed to send the engine the "unlock" when it lost focus.

The only condition that would be "dual focus" is if you type and the character typed appears simultaneously in two places.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Double focus when Subforms are used
Reply #9 - Apr 12th, 2004 at 3:40pm
Print Post Print Post  
Ok, I got it, it is not related to double focus. However, I am not talking about a single event  This is a pattern that is repeated everytime and with 100% predictability, it can be reproduced even in a single user non-networked environment. Does that mean it is an unrelated bug?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #10 - Apr 12th, 2004 at 3:54pm
Print Post Print Post  
It doesn't matter if you are networked or not. There is still always a client and a server. Networking just determines how they talk to each other. When standalone, the client talks to a "pipe", the server reads from that pipe and responds to the client through a similar pipe. When client/server, the client talks to a pipe. A "server proxy" reads that pipe and tells the network (a "socket"). A "client proxy" reads that socket and talks to a pipe. The server then reads that pipe.

So a message going from the client to the server follows these paths:

Standalone:
client->pipe->server

Client/Server:
client->pipe->server_proxy->||socket||->client_proxy->pipe->server

That way the client, nor the server, have to act any differently because they are standalone, or client/server. They always "think" they are talking to each other through the pipe.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #11 - Apr 12th, 2004 at 4:05pm
Print Post Print Post  
I guess this is a missunderstanding in terminology - when I say "focus" - I mean "keyboard focus" a pretty specific GUI concept. We may not be talking about focus here, but rather about "current LE" - a much less specific animal.

You'll notice that this conversation started with Carl mentioning the highlighting around an LE. If you look carefully you will notice that there are actually two different highlights that can appear. One that has a solid line and one that has a dotted line. The highlighting is controlled from two different points. One is caused by the Focus event. The other is actually caused by the "spec handler". They usually coincide - but not always. In which case, which LE is "current"? That depends on what you are doing. If you are typing in an LE - then the "focused" LE is current. But if you are working with a spec, the "spec highlighted" LE is current.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Double focus when Subforms are used
Reply #12 - Apr 12th, 2004 at 4:06pm
Print Post Print Post  
Quote:
It may be that the server is sending the "lock" message and any form that has that record is locking. The table may have failed to send the engine the "unlock" when it lost focus.


Your above quote gives me impression that something is not right .... something failed to send engine "Unlock" ... 

Is this normal or aberrant?

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #13 - Apr 12th, 2004 at 4:12pm
Print Post Print Post  
It is speculation - at the moment. I'm guessing that the table knows to send lock/unlock when you move from row to row, but is neglecting to send if you move completely out of the table. If that is the case, it is a bug.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Double focus when Subforms are used
Reply #14 - Apr 12th, 2004 at 4:18pm
Print Post Print Post  
Quote:
I'm guessing that the table knows to send lock/unlock when you move from row to row, but is neglecting to send if you move completely out of the table. If that is the case, it is a bug.


I believe that is the case. If you need me to send you the application, I will do that for you to see what I am talking about.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Double focus when Subforms are used
Reply #15 - Apr 13th, 2004 at 4:38am
Print Post Print Post  
Mark,

I do believe we haven't understood each other due to terminology. Based on what you posted here, when I say "focus", I actually mean "current LE", I think.

I guess what I was asking, was if there is a way for subforms to simply display the field information without actually needing the "current LE" status to be in one of the subform elements as it creates the rows of a table view subform. Because with true focus (cursor in element) on a main form, the subform entry events are executing as the main form is advanced. Is it possible to have "NO current LE"? Or while focus is actually in the main form, maybe programming should be deactivated for the subform (similar to Shift-F6), and activated when focus is placed in the subform.

If not, maybe we simply need to use the workaround that I am using. I have an On Form Exit event with a goto command that sends "current LE" status to an element that has absolutely no programming in it. That seems to have solved my problem.

(I understand that it must be very difficult to predict every way users will try to bend and twist Sesame. And I don't envy the pressure you must be under to please everyone's personal preferences. I appreciate your commitment and effort to continue to put up with us and our whining. Wink)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Double focus when Subforms are used
Reply #16 - Apr 13th, 2004 at 11:54am
Print Post Print Post  
Quote:
I have an On Form Exit event with a goto command that sends "current LE" status to an element that has absolutely no programming in it. That seems to have solved my problem.


Carl,
Is the on form exit event  sending "current LE" status to an element that has absolutely no programming in it in  the subform or parent?


Quote:

(I understand that it must be very difficult to predict every way users will try to bend and twist Sesame. And I don't envy the pressure you must be under to please everyone's personal preferences. I appreciate your commitment and effort to continue to put up with us and our whining. Wink)


I will second your comments on this!  Cheesy
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Double focus when Subforms are used
Reply #17 - Apr 13th, 2004 at 1:09pm
Print Post Print Post  
Quote:
Is the on form exit event  sending "current LE" status to an element that has absolutely no programming in it in  the subform or parent?

It's in the subform. ([FormName] :: On Form Exit)

And I put it in an EXIT event, because that way I can be sure which element has "current" status before entering the next form. (Usually, Form On Form Entry executes before Element On Form Entry, but I seem to remember it happening in the opposite order once. So, to be SURE, I put it in the exit event.)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged