Get a Jumpstart with our Sample Apps
Results 1 to 15 of 15

Thread: possible to change the focus to the SAVE button?

  1. #1
    Member
    Real Name
    Ron Leunis
    Join Date
    Sep 2005
    Location
    Netherlands
    Posts
    652

    Default possible to change the focus to the SAVE button?

    Hi,

    I have a grid with detailview which is updateble.
    It has the Cancel, Delete and Save buttons on the detailview part.

    Now, I noticed that when a user opens an occurence in the grid, and the user goes to one of the fields of the detailview with the cursor, then the default FOCUS is on the DELETE button. I use the Buttondown CSS

    It happened a couple of times that the user changes some data on the detailview and presses the keyboard ENTER button...

    With result that the record/occurence is deleted instead of the user's intention to SAVE...

    Is it possible to change the focus to the SAVE button? And if yes, how please.

    thanks, Ron
    Last edited by rleunis; 01-18-2006 at 01:31 PM.

  2. #2
    Member
    Real Name
    Ron Leunis
    Join Date
    Sep 2005
    Location
    Netherlands
    Posts
    652

    Default Focus please

    Focus please. How to change from Delete Buttton to Save button...

  3. #3
    Member
    Real Name
    Ron Leunis
    Join Date
    Sep 2005
    Location
    Netherlands
    Posts
    652

    Default Highlighting of DELETE button

    Hi,

    The lack of response maybe indicates that my wording of the problem was not in good English...(Sorry, from the Netherlands).

    I have attached a picture to clarify the problem further.

    When I enter Detail View mode and put the cursor in a field of the detailgrid, the DELETE button highlights (gets focus) automatically.

    Is there a way that I can change the focus (highlighting of a button) to the SAVE button?

    Regards, Ron

  4. #4
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,752

    Default

    I don't think there's any problem with your english. I suspect nobody who has looked at it so far has an answer. I don't - sorry. We can only hope that somebody will pick up on it tomorrow and know what to do.

  5. #5
    Alpha Software Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,158

    Default Changing the order of buttons

    The problem is not your english - it is fine. The problem is that there isn't a good solution.

    When you are working with browsers, html, and JavaScript, many actions are defined by common web standards. These standards result in behavior that may not fit every situation. Because they are standards that allow almost all browsers to work the same, they can't be changed and you have to work around them. This is just one example.

    Strictly speaking, there is no action in html to capture the "Enter" button action. Most browsers are "helpful" and highlight the first submit button in a form element when focus is placed on an object in the form. This is done to allow an "enter" button push to "push" a button. Since the Delete button is shown before the submit button, it has focus. This can not be changed.

    The best way to change this is to change the order of the buttons and place the submit button first. There is currently no method in the components to change the order of the buttons.

    However, there are a few solutions currently available to you. The easiest is to add a "Confirm before delete" action to the detail view properties. If the user accidentally "presses" the delete action, a confirmation message will pop up that should get their attention.

    The second method is more complex. You can change the html generated by the component after it has been created on the page. Html is just text. Therefore any character replacement functions will work. The trick is to find the text for the buttons, and "reverse" them. This is done by modifying the code using the source tab view for the page. Here is an example for a component name "grd_cust". The first 2 lines would already exist in the code when viewed on the source tab. The code below the line is added.

    HTML Code:
    x_grd_cust = a5w_run_Component(tmpl_grd_cust)
    '=============================================================================================================
    
    button1 = "value=\"Save\" name=\"grd_cust_DetailView_Save\""
    button2 = "value=\"Delete\" name=\"grd_cust_DetailView_Delete\""
    
    x_grd_cust.Output.Body.DetailView_HTML = stritran(x_grd_cust.Output.Body.DetailView_HTML,button1,button2)
    x_grd_cust.Output.Body.DetailView_HTML = stritran(x_grd_cust.Output.Body.DetailView_HTML,button2,button1,1,1)
    The text in "button1" matches the text in the generated html of the detail section for the "save" button.
    The text in "button2" matches the text in the generated html of the detail section for the "delete" button
    The text to replace will be found in the "DetailView_HTML" output from the component
    The first replacement changes the code for the "Save" button to the code for the "Delete" button. At this point, there will be 2 delete buttons
    The second replacement changes the code for only the first "delete" button to the code for the the "save" button.
    The Save button is now before the delete and will have focus.

    This same character replacement concept can be used to replace any gereated html with other html.

  6. #6
    Member
    Real Name
    Ron Leunis
    Join Date
    Sep 2005
    Location
    Netherlands
    Posts
    652

    Default

    Jerry,

    Thanks for the clarification. I will add the confirmation question and will try the suggestions for the turnaround of the buttons.
    Regards, Ron

  7. #7
    Alpha Software Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,158

    Default

    As an update, the order of the buttons will be changed in one of the next builds. The Save button will be placed before the Delete in the component design.

  8. #8
    Member
    Real Name
    Ron Leunis
    Join Date
    Sep 2005
    Location
    Netherlands
    Posts
    652

    Default

    Thanks again.
    It would be nice if it would be possible to change the order of buttons in gridcomponents for this, like I think it is possible for dialog components as part of the genie.

    Ciao, Ron

  9. #9
    Member B.B.Bongers's Avatar
    Real Name
    Ing./BICT Brendo Bongers
    Join Date
    Jun 2006
    Location
    Netherlands
    Posts
    139

    Default Re: possible to change the focus to the SAVE button?

    With javascript this will focus an element on a form:

    Example:
    this will put a focus on a element when the page is loaded.
    Another more suitable solution is to disable the delete button when a user pushes the "add new record" . The delete button will gray-out.

    onclick="document.form.deletebutton.disabled=true;"

    <!-- Define the function giving the focus -->
    <SCRIPT LANGUAGE="JavaScript">


    function giveFocus(element)
    ...{
    if(document.formName.elementName!=null)
    {
    ......document.formName.elementName.focus();
    ...}

    }


    </SCRIPT>
    </HEAD>

    <BODY ONLOAD="giveFocus(elementName);">
    <FORM NAME="formName">
    <INPUT TYPE="button" NAME="elementName" VALUE="save">
    </FORM>
    </BODY>
    </HTML>
    Last edited by B.B.Bongers; 07-01-2006 at 07:15 AM.
    Ing./bict Brendo Bongers
    Software Engineer

    http://www.brendobongers.nl

    "There's more than one way to skin a cat."

  10. #10
    Member
    Real Name
    Alan Sawyer
    Join Date
    Apr 2006
    Location
    western New York (rural)
    Posts
    200

    Default Re: possible to change the focus to the SAVE button?

    Can I get the first fieild in my dialog component to have the focus in a similar manner even with other fields on the form? I have a form that have some enterable fields on it, but I want the user to go directly to the first field in the dialog component automatically.
    Alan Sawyer

  11. #11
    Member B.B.Bongers's Avatar
    Real Name
    Ing./BICT Brendo Bongers
    Join Date
    Jun 2006
    Location
    Netherlands
    Posts
    139

    Default Re: possible to change the focus to the SAVE button?

    Hi Alan,

    Yes you can.
    You only have to know the name(html attribute name="yourelement") of the first field. What kind of element is it? A textfield?

    Kind regards

    Brendo
    Ing./bict Brendo Bongers
    Software Engineer

    http://www.brendobongers.nl

    "There's more than one way to skin a cat."

  12. #12
    Member
    Real Name
    Alan Sawyer
    Join Date
    Apr 2006
    Location
    western New York (rural)
    Posts
    200

    Default Re: possible to change the focus to the SAVE button?

    It is a text field called txtBusName
    Does it still go in the main a5w page?? I'm still very new at WAS so I don't fully understand how it all works yet, but over the next couple of months I hope to learn much much more.
    Thanks for any help.
    Alan

  13. #13
    Member B.B.Bongers's Avatar
    Real Name
    Ing./BICT Brendo Bongers
    Join Date
    Jun 2006
    Location
    Netherlands
    Posts
    139

    Default Re: possible to change the focus to the SAVE button?

    You have place the javascript code on the page where the textfield resides..(the function between the hml head tags)

    Javascript has nothing to do with WAS.
    Javascript is clientside and operates on html/dom objects. I would say give it a try! Just "trial and error", best way to learn I think:)
    You could take a look at www.deguru.com. They have a lot of basic but essential information about wellknown languages including javascript/html/css.

    Kind regards
    Ing./bict Brendo Bongers
    Software Engineer

    http://www.brendobongers.nl

    "There's more than one way to skin a cat."

  14. #14
    Member B.B.Bongers's Avatar
    Real Name
    Ing./BICT Brendo Bongers
    Join Date
    Jun 2006
    Location
    Netherlands
    Posts
    139

    Default Re: possible to change the focus to the SAVE button?

    Rectification:
    http://www.devguru.com/
    Ing./bict Brendo Bongers
    Software Engineer

    http://www.brendobongers.nl

    "There's more than one way to skin a cat."

  15. #15
    Member
    Real Name
    ken tjia
    Join Date
    Jan 2008
    Location
    Vancouver, BC Canada
    Posts
    560

    Default Re: Changing the order of buttons

    Quote Originally Posted by JerryBrightbill View Post
    The problem is not your english - it is fine. The problem is that there isn't a good solution.

    When you are working with browsers, html, and JavaScript, many actions are defined by common web standards. These standards result in behavior that may not fit every situation. Because they are standards that allow almost all browsers to work the same, they can't be changed and you have to work around them. This is just one example.

    Strictly speaking, there is no action in html to capture the "Enter" button action. Most browsers are "helpful" and highlight the first submit button in a form element when focus is placed on an object in the form. This is done to allow an "enter" button push to "push" a button. Since the Delete button is shown before the submit button, it has focus. This can not be changed.

    The best way to change this is to change the order of the buttons and place the submit button first. There is currently no method in the components to change the order of the buttons.

    However, there are a few solutions currently available to you. The easiest is to add a "Confirm before delete" action to the detail view properties. If the user accidentally "presses" the delete action, a confirmation message will pop up that should get their attention.

    The second method is more complex. You can change the html generated by the component after it has been created on the page. Html is just text. Therefore any character replacement functions will work. The trick is to find the text for the buttons, and "reverse" them. This is done by modifying the code using the source tab view for the page. Here is an example for a component name "grd_cust". The first 2 lines would already exist in the code when viewed on the source tab. The code below the line is added.

    HTML Code:
    x_grd_cust = a5w_run_Component(tmpl_grd_cust)
    '=============================================================================================================
    
    button1 = "value=\"Save\" name=\"grd_cust_DetailView_Save\""
    button2 = "value=\"Delete\" name=\"grd_cust_DetailView_Delete\""
    
    x_grd_cust.Output.Body.DetailView_HTML = stritran(x_grd_cust.Output.Body.DetailView_HTML,button1,button2)
    x_grd_cust.Output.Body.DetailView_HTML = stritran(x_grd_cust.Output.Body.DetailView_HTML,button2,button1,1,1)
    The text in "button1" matches the text in the generated html of the detail section for the "save" button.
    The text in "button2" matches the text in the generated html of the detail section for the "delete" button
    The text to replace will be found in the "DetailView_HTML" output from the component
    The first replacement changes the code for the "Save" button to the code for the "Delete" button. At this point, there will be 2 delete buttons
    The second replacement changes the code for only the first "delete" button to the code for the the "save" button.
    The Save button is now before the delete and will have focus.

    This same character replacement concept can be used to replace any gereated html with other html.
    Hi Jerry, suppose we apply this on the default alpha log in grid, how do i force the cursor to be on the "user ID" entry field.

    i do not want to focus on submit or cancel.
    any consideration of making it easier, instead of altering the java codes.
    thanks
    ken tjia

Similar Threads

  1. Disable button unless browse has focus?
    By Lawrence Fox in forum Alpha Five Version 7
    Replies: 0
    Last Post: 01-13-2006, 12:22 AM
  2. button focus color
    By Bobby Neal in forum Archived Wishlist
    Replies: 1
    Last Post: 11-03-2004, 09:42 AM
  3. How do you change object focus?
    By Newton Thomas in forum Alpha Five Version 5
    Replies: 3
    Last Post: 10-19-2004, 10:23 AM
  4. how do I label color change on focus?
    By David Mason in forum Alpha Five Version 4
    Replies: 1
    Last Post: 11-25-2001, 06:25 AM
  5. Save Button That Highlights When Not Save?
    By Don Reed in forum Alpha Five Version 4
    Replies: 1
    Last Post: 04-01-2000, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •