OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to default focus on new form record to first field

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
timinak
General User
General User


Joined: 03 Mar 2011
Posts: 28
Location: Palmer Alaska

PostPosted: Sun May 13, 2012 5:33 pm    Post subject: How to default focus on new form record to first field Reply with quote

Using OO 3.2 on Ubuntu 10.04. Have a form designed.
Automatic Control Focus is set to on. Thus, when the form
is first opened, the focus is on the first field. Good.
When a record is edited or created and the next button is clicked,
Focus is on the same field as was in focus in the previous record.
Bad
How can I insure that focus is always on the first field for a new record?
It is driving my wife crazy. Help me save my marriage. No, just kidding, but
help me to put her in a better mood.Wink
thanks
tim
_________________
Programmer 24 years. Linux, Mac
command-line. New to OO
Back to top
View user's profile Send private message
dacm
Super User
Super User


Joined: 07 Jan 2010
Posts: 769

PostPosted: Mon May 14, 2012 12:46 pm    Post subject: Re: How to default focus on new form record to first field Reply with quote

tim,

That's beyond the function of 'Automatic Control Focus' (which only functions upon initially opening the Form). But a Macro could do the trick:
Code:
Sub SetFocus 'Form > Events > After Record Change
   '   replace ("names") below with the names of your Form(s) and focused Control as necessary
   oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")'.getByName("SubForm")
   cControl = oForm.getByName("Table Control 1") 'replace with the name of the Control receiving focus
   oControlView = ThisComponent.CurrentController.getControl(cControl) 'workaround...API should expose the View from oControl
   oControlView.SetFocus
'   wait 100 'may be necessary before next step with slower CPU's
'   oControlView.setCurrentColumnPosition(0) 'additional step to select a specific column within a Table Control (grid)
End Sub

_________________
Soli Deo gloria
Tutorial: avoiding data loss with Base + Splitting 'Embedded databases'


Last edited by dacm on Mon May 14, 2012 8:27 pm; edited 3 times in total
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Mon May 14, 2012 1:45 pm    Post subject: Reply with quote

Hello

When you play with the tab-order in the form can you get what you want?

Romke
_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
timinak
General User
General User


Joined: 03 Mar 2011
Posts: 28
Location: Palmer Alaska

PostPosted: Mon May 14, 2012 2:22 pm    Post subject: Reply with quote

Hello dacm:

I'm not surprised it would take a macro. I did take a look at macros
available and couldn't find what I wanted. Thanks very much. I will give that a try.

Oh, and RPG, I set the TAB order to coincide with the physical order of the fields,
going from left to right and 'uppermost' line to lowermost.
Could you elaborate on your comment?

Othewise, I looking forward to practicing on my first macro. Idea
cheers
tim
_________________
Programmer 24 years. Linux, Mac
command-line. New to OO
Back to top
View user's profile Send private message
dacm
Super User
Super User


Joined: 07 Jan 2010
Posts: 769

PostPosted: Mon May 14, 2012 2:39 pm    Post subject: Reply with quote

RPG wrote:
When you play with the tab-order in the form can you get what you want?

The tab-order determines which Control receives the focus upon opening a Form with 'Automatic Control Focus' selected/enabled. Otherwise, if 'Automatic Control Focus' is not selected, no Control receives focus and the user must select a Control manually -- so 'Automatic Control Focus' saves a mouse-click.

Once interaction with the Form commences, 'Automatic Control Focus' doesn't seem to apply. Tab-order works as advertised when tabbing, but doesn't drive the focus back to the first Control in tab-order when changing records (navigating between records). The focus simply remains on the last selected Control.

So I think we're left with a macro-driven solution... Question
_________________
Soli Deo gloria
Tutorial: avoiding data loss with Base + Splitting 'Embedded databases'
Back to top
View user's profile Send private message
timinak
General User
General User


Joined: 03 Mar 2011
Posts: 28
Location: Palmer Alaska

PostPosted: Mon May 14, 2012 2:47 pm    Post subject: Reply with quote

Indeed, a macro-based solution it is. Thanks again
_________________
Programmer 24 years. Linux, Mac
command-line. New to OO
Back to top
View user's profile Send private message
dacm
Super User
Super User


Joined: 07 Jan 2010
Posts: 769

PostPosted: Mon May 14, 2012 3:01 pm    Post subject: Reply with quote

timinak wrote:
...I looking forward to practicing on my first macro. Idea

Macros are often necessary to tweak Form usability for end-users. But in the early stages of learning Base, don't assume you need a macro until searching or posing the question in these forums -- just as you've done. You'll be amazed what Base can do without macros. Besides, folks won't always write macros for you and over-reliance on macros can undermine proper database and/or Form design which can cause bigger problems down the road.
_________________
Soli Deo gloria
Tutorial: avoiding data loss with Base + Splitting 'Embedded databases'
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Mon May 14, 2012 3:38 pm    Post subject: Reply with quote

Hello

I did not read careful enough the question. I was thinking the problem was only for the first field and I did not see also a new record.

I think the solution of DACM is right. When you want only add data then you can go to a new record. Set the form to: add data only.

Romke
_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Tue May 15, 2012 2:15 am    Post subject: Reply with quote

Hello

After better reading I do understand better the problem. I'm not sure if it works always and also if you can use it.

Code:
sub Activatefirst_AfterRecord_change(oEvent as object)
Thiscomponent.currentcontroller.getFormController(oEvent.source).activateFirst
end sub


Romke
_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Tue May 15, 2012 2:24 am    Post subject: Reply with quote

Hello

This can work when you want set the focus on an other control then the first one.

Code:
sub Activatefirst_AfterRecord_change(oEvent as object)
dim oFormController
oFormController=Thiscomponent.currentcontroller.getFormController(oEvent.source)
oFormController.controls(3).setfocus
end sub

_________________
OOo 3.4.5 on openSUSE 12.1
Use this forum : http://user.services.openoffice.org/en/forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group