Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

OnKey Event for newbies

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OnKey Event for newbies

    I'm working on a form with an embedded browse trying to build a "search" field on the form. I have a number of action scripts that run fine but the problem is that I've only been able to trigger them by putting them in the "OnChange" object event. From what I can tell, some Xbasic scripting knowledge is needed to take advantage of the onKey event.

    I will be moving the working scripts from OnChange to OnKey. Then, I'd like the Enter key to run the action scripts, but only if the user is on the Search field.
    Is there a way to use OnKey without converting my existing action scripts into xbasic?

    Thanks!

  • #2
    Re: OnKey Event for newbies

    Just out of interest here, why not leave it with the Onchnge of the search field ?
    I've never done that but does not sound like a bad idea.

    Comment


    • #3
      Re: OnKey Event for newbies

      Its just been my experience that although it works using the Onchange event, its not ideal. It will run even though something has been typed in there by accident and the user just wants to get out of the field. Or if you re-enter the same information, it doesn't see the change so it doesn't run anything.
      This form is designed to work with a barcode scanner,
      It would work much better if there was a way to have it execute on the press of ENTER or by using a form button. Take website's search field, for example google's search...you can input whatever you like but it doesn't execute the search until the user presses ENTER or uses the Search button.

      Comment


      • #4
        Re: OnKey Event for newbies

        You could try the OnDepart event for your script. That will trigger when the user uses the Enter or Tab key to exit.
        Robin

        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

        Comment


        • #5
          Re: OnKey Event for newbies

          To mimic the behavior you describe, place a square button to the right of the search field, move the code from the OnChange to the button. Finish with a magnifier logo on the button.

          Comment


          • #6
            Re: OnKey Event for newbies

            The problem with only having a button is that you lose the ability to use the form with a scanner. The user will be forced to scan the part and then come back to the PC to use the mouse just to click on the button. The scanner automatically sends data and adds the Enter key command at the end of the string.

            Comment


            • #7
              Re: OnKey Event for newbies

              Go with Robin's suggestion. Make sure your scanner is set to add ENTER to the scan.

              Comment


              • #8
                Re: OnKey Event for newbies

                Sounds good, however, I'm not sure how to start it...we only want it to run OnDepart and when Enter is used. I'm not experienced with xbasic at all, it currently runs a number of action scripts. Is there a way to preserve those and add the Enter key functionality? Guessing it would be an OnDepart event and within it I would check off 'Action is Conditional' but I'm stuck after that.

                Comment


                • #9
                  Re: OnKey Event for newbies

                  Code:
                  if johns_condition then    'If true
                   
                      if a_user.key.value = "{ENTER}" THEN
                        'set a_user.key.handled = .t. to prevent the key stroke being passed on to the Form
                        a_user.key.handled = .t.
                      
                       do something
                  
                       end if    
                   end if
                  But I think it would be better to have the OnKey event check and see if the object (form field) has focus and if so do the enter thing.

                  Comment


                  • #10
                    Re: OnKey Event for newbies

                    This will only run your script if the enter key is pressed while a certain field has focus.
                    It would be in the OnKey event for the form.

                    Code:
                    dim obname as c
                    obname = :formname.Active()
                    
                    if obname = "ObjectName" then
                    
                    	if a_user.key.value = "{ENTER}" then
                    	    a_user.key.handled = .t.
                    	    script_play("yourscript")
                    	end if    
                    
                    end if
                    Replace :formname. with the name of your form.
                    Replace "ObjectName" with the object name for the field on the form
                    Replace "yourscript" with the name of the script you want to run if the enter key is press while the field has focus.

                    Comment


                    • #11
                      Re: OnKey Event for newbies

                      Hi Preston,

                      I'm currently trying to implement your suggestion. So how would I go about using your code (xbasic) along with my original action scripts built with genies. I rather not convert them to xbasic because I will be in trouble if necessary to edit something. Any work around?

                      Comment


                      • #12
                        Re: OnKey Event for newbies

                        Update:
                        So i went ahead and copied the original action scripts into a New Global Script which is run as you suggested above.
                        One of the action scripts includes a 2 button dialog box which is giving me issues when using the Enter key to close out the dialog and return to the form. It keeps running the script every time I hit enter even though the dialog box is what has focus...

                        Comment


                        • #13
                          Re: OnKey Event for newbies

                          If you use a button to run your scripts all the OnDepart field event has to do is push the button, and no mouse action is needed.

                          Yourbuttonname.push().

                          If the 2 action scripts need tweaking you can peek at the xbasic and copy and paste those scripts here. Otherwise there is not much more advice anyone can give you.
                          Last edited by MoGrace; 04-22-2016, 10:11 AM.
                          Robin

                          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                          Comment


                          • #14
                            Re: OnKey Event for newbies

                            Back at this again, Preston's suggestion works great. I'd like to be able to incorporate this to work with the script genie if possible so I don't need to convert the genie scrips into Xbasic.
                            Is there a way to convert Preston's code into something that can be run on a condition?

                            Here is the dialog created using the genie:
                            'Prompt for text and store result in a variable called 'vworknum'.
                            dim prmpt_title as c
                            dim prmpt_prompt as c
                            dim prmpt_default as c
                            dim prmpt_format as c

                            prmpt_title = "Work Number"
                            prmpt_prompt = "Enter Work Number"
                            prmpt_default = ""
                            prmpt_format = "00000"

                            DIM SHARED vworknum AS C

                            vworknum = ui_get_text(prmpt_title,prmpt_prompt,prmpt_default,prmpt_format)

                            Comment


                            • #15
                              Re: OnKey Event for newbies

                              First, you can add an action script element, xbasic, inline xbasic, and place your code there. That action script element can be conditional just like any other.
                              There can be only one.

                              Comment

                              Working...
                              X