Hi,
During the building and testing of my modules, it disturbes me that whenever I open a new page I have to set the focus to the first field to be entered with the mouse.
Is there a code part that I can push in to my coding that tells the webpage to focus on the first field that I define.
Example: when I open up the admin login screen of a CMSMS website, the focus (the cursor) is on the username. I can start typing immediately. When I use, in the back end, Content, Pages, Edit page: home, I can't find the active field/button. I would expect it to be on the content type or title.
The same is true for the modules that I build.
So how to set the focus to the content type field.
Duketown
Using IE7
[Edit: Same situation in Google Chrome]
[Solved] Set cursor in first field on screen to filled
[Solved] Set cursor in first field on screen to filled
Last edited by Duketown on Thu Oct 23, 2008 5:33 am, edited 1 time in total.
Re: Set cursor in first field on screen to filled
Hi Duketown,
I've never come across something like this in the API, it's a goo idea. I wonder does CGExtensions provide this for CMSMS?
Alan
I've never come across something like this in the API, it's a goo idea. I wonder does CGExtensions provide this for CMSMS?
Alan
--
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
Alan Ryan
Lead Developer
CodeCrunchers Internet Software Development - Ireland
http://www.codecrunchers.ie
Re: Set cursor in first field on screen to filled
Use some Javascript to do it for you? Use tab index for the form fields (not so good)...
Re: Set cursor in first field on screen to filled
Is Javascript the only possible solution?
During development in whatever language I try to put in code to overcome RSI and to make it easy for the end user. Isn't this then a HTML problem?
Duketown
During development in whatever language I try to put in code to overcome RSI and to make it easy for the end user. Isn't this then a HTML problem?
Duketown
Re: Set cursor in first field on screen to filled
Hi,
I did some research in the coding. It appears that in the login script the input field 'User name' gets the class="defaultfocus". In the themes directory there is /includes/standard.js (yes, the javascript that Russ is maybe referring to). Reading that script, you will come cross a function called defaultfocus(), which is called during the loading of a window (at least that is what I make of it).
Just above the function defaultfocus() is also some comment: //use
So I tried to change the template that I wanted to have the first field a focus on by changing its class: in stead of
I see that the line up of the fields is changing (due to the css settings of pageinput I think), but no change on the focus to the field it self.
Now I did my change on the part and not on the part. So I had to remove 'class="defaultfocus"' from the template and into the input generation part. I changed the line in the connected program as follows:
The , 'class="defaultfocus"' makes the difference
.
If it concerns a CreateInputDropdown field, you will not see the autofocus immediately, but using the tab key once will highlight the contents letting you know the field is in focus.
Duketown
I did some research in the coding. It appears that in the login script the input field 'User name' gets the class="defaultfocus". In the themes directory there is /includes/standard.js (yes, the javascript that Russ is maybe referring to). Reading that script, you will come cross a function called defaultfocus(), which is called during the loading of a window (at least that is what I make of it).
Just above the function defaultfocus() is also some comment: //use
So I tried to change the template that I wanted to have the first field a focus on by changing its class:
Code: Select all
<p class="defaultfocus">{$inputname}</p>
Code: Select all
<p class="pageinput">{$inputname}</p>
Now I did my change on the part and not on the part. So I had to remove 'class="defaultfocus"' from the template and into the input generation part. I changed the line in the connected program as follows:
Code: Select all
...assign('inputname', ...CreateInputText($id, 'name', $name, 40, 80, 'class="defaultfocus"'));

If it concerns a CreateInputDropdown field, you will not see the autofocus immediately, but using the tab key once will highlight the contents letting you know the field is in focus.
Duketown
Last edited by Duketown on Thu Oct 23, 2008 5:49 am, edited 1 time in total.