Normal Topic Cursor position (Read 824 times)
Rather be outside
Member
*
Offline



Posts: 12
Joined: Jan 25th, 2007
Cursor position
Apr 8th, 2007 at 5:09pm
Print Post Print Post  
Using comand buttons on a custom menu, is there a way to reliably position the cursor in the first field on the form so that the operator can click the command button and begin typing?  I.E.  click or press "Enter" on "Get a Part Number", and put the cursor in the PartNumber LE, ready to accept input.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Cursor position
Reply #1 - Apr 8th, 2007 at 5:51pm
Print Post Print Post  
ThrowFocus will set focus from the button to another element on the same form. Remember that it will not move focus until all other programming in the current event, or any queued events has completed.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rather be outside
Member
*
Offline



Posts: 12
Joined: Jan 25th, 2007
Re: Cursor position
Reply #2 - Apr 8th, 2007 at 7:07pm
Print Post Print Post  
"ThrowFocus will set focus from the button to another element on the same form."

By definition, the command button on a custom menu is on a different form from the element I want the cursor to end up in.  however, same problem exists if I use the Application menu and Choose Search/Update!Parts!Parts.  I then have to click in the desired LE with the mouse or TAB to get the cursor in the LE.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Cursor position
Reply #3 - Apr 8th, 2007 at 8:02pm
Print Post Print Post  
Quote:
"ThrowFocus will set focus from the button to another element on the same form."

By definition, the command button on a custom menu is on a different form from the element I want the cursor to end up in.


Many users have a custom menus across the top or side of their forms - forms that contain other elements. These are also "custom menus" using command buttons. So rather than simply assume that that was or was not the case, I qualified my statement so as to make it clear that ThrowFocus, as part of form programming, will not throw focus from one form to another.

In any case, from the button on the menu form (using the Customers.db form names):

Code
Select All
var r as int

r = @SelectTreeItem("Sample Customers Application!Forms!Search/Update!Customers!Main Form")
 



On the target form's GLOBAL CODE (using element Add1 as the target):
Code
Select All
if(@Mode() = 2)
{
  ThrowFocus(Add1)
}
 



In the target form's On Retrieve Spec Open event:
Code
Select All
ThrowFocus(Add1)
 


  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Cursor position
Reply #4 - Apr 9th, 2007 at 1:08am
Print Post Print Post  
Quote:
On the target form's GLOBAL CODE (using element Add1 as the target):
Code
Select All
if(@Mode() = 2)
{
  ThrowFocus(Add1)
}
 



In the target form's On Retrieve Spec Open event:
Code
Select All
ThrowFocus(Add1)
 



Mark,

Aren't these redundant?

(Like the 2nd example, I simply use a ThrowFocus command located only in the On Retrieve Spec Open event, because that is the only form mode that doesn't already put the cursor in the first LE.)
  


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: Cursor position
Reply #5 - Apr 9th, 2007 at 1:37am
Print Post Print Post  
Quote:
Mark,

Aren't these redundant?

(Like the 2nd example, I simply use a ThrowFocus command located only in the On Retrieve Spec Open event, because that is the only form mode that doesn't already put the cursor in the first LE.)


Yes. They are redundant. But this approach stands the best chance of working under each of the different ways to get to the search form.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rather be outside
Member
*
Offline



Posts: 12
Joined: Jan 25th, 2007
Re: Cursor position
Reply #6 - Apr 9th, 2007 at 2:34am
Print Post Print Post  
The suggested programming works.  I had tried ThrowFocus in different places with inconsistent results, which led to the post.

I have another problem, related to this one -- is there a way to open a tabbed form in Search/Update on any of the tab pages other than the first one?  I accidentally did this by saving and reconciling a form from the second or third tab page, and then it would always open to that page, but I only want to do that in certain instances.

Thanks for your help.
  
Back to top
 
IP Logged